Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125631 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id A5CC21A00BD for ; Thu, 19 Sep 2024 12:31:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1726749199; bh=KGwr4OQPRulVeoZNnUST6+LaGggAhtgAMlYEE2HFrTU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Dp23jrBgtoV5yOvMNg1B8XtTsuwq/vS856DTT7ttbLRwOnSsDu+q+S8h0epL7a0t9 8HWPAQJcWW2SndzYHFTSk2NBUpMQOtdE1PupcW15DY8HQWynGsXlIEozhcTmp7xUWd iU9xeujvrKDCj/id0/bzyzt0MITce7lriqYOB0/VeHVjsDwdpiXkxgG2HUKom+pfWM kmF8D2XbqzIgjO+C8xPfVrrpYpoY6oTEuIkVMU8mleFL70xq/JMAOBq8oqBD+lfDDP AZcFm8fYN9t7OOV+IXOUUW+2ajNso1IkpJikzb2nz0MkAWfJtGAXqLwjyD7z6GBo+Y XliBW0cECA1ag== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0DFAD180042 for ; Thu, 19 Sep 2024 12:33:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 19 Sep 2024 12:33:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1726749071; bh=Lno2cCrNsbObiBdTs3vQACPchohQJgL8MH+xnk3FXlI=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=WAgSyVaRX5Q9RUibX7ZzIXVX+7dymso15UdknB4X2rhw4CJPiQGFGy86f4Smu6fGP bDg3yxJ1nAle78n1L9vCZQqCQjHVtA1c8m4nhcNQkEhgYGkOIheoJfOIj2pFugk5vY 9QT8TQ77BaIX1992LGVdwte8jH0qnjfGsQRetolyv7KzIIJv18ugQCbeVgJ4mnoub/ /wu4roHp/RCCJIDGDLJguBfFHileYjns8wlGeiqKkO8vInM/VzVNAcszfwEtX7098G mzwfb+zJaSezUy+SPKQCriEmzaXkUzORukrpHfB1eUw+uR9gpm1tvHOol297n7fzmO XLiUXRZSRCJug== Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Thu, 19 Sep 2024 14:31:10 +0200 To: "Christoph M. Becker" Cc: Vincent Langlet , PHP Internals List Subject: Re: [PHP-DEV] strrchr with needle with multiple characters In-Reply-To: References: Message-ID: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi Am 2024-09-02 15:24, schrieb Christoph M. Becker: > Now, comparing strstr() and strrchr() is of course still possible, but > different behavior is less astonishing. Of course, strrchr() could > warn > or even throw if $needle has more than one character, but that may > unnecessarily break code for a small benefit. I would expect that passing more than one character to `strrchr()` is very likely to be an accident or a misunderstanding of how the function behaves and thus already broken. A warning would just visibly point out that it is broken, instead of it silently behaving in a manner that diverges from the user's expectations (possibly unpredictably if the function is working on untrusted / user input). If the function would be newly introduced, I'd make it an error to pass more than one character, but given that the function already exists, I'd say that pointing out such mistakes is exactly what the Warning / Notice facility is for. Best regards Tim Düsterhus