Re: Proposal for a new basic function: str_contains

From: Date: Mon, 17 Feb 2020 11:55:53 +0000
Subject: Re: Proposal for a new basic function: str_contains
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-108646@lists.php.net to get a copy of this message
On Mon, Feb 17, 2020 at 12:49 PM Benjamin Morel <benjamin.morel@gmail.com> wrote: > Thanks for the karma! An RFC has been created: >> https://wiki.php.net/rfc/str_contains > > > > Something that's missing from the RFC is the behaviour when $needle is an > empty string: > > str_contains('abc', ''); > str_contains('', ''); > > Will these always return false? > As of PHP 8, behavior of '' in string search functions is well defined, and we consider '' to occur at every position in the string, including one past the end. As such, both of these will (or at least should) return true. The empty string is contained in every string. Regards, Nikita

« previous php.internals (#108646) next »