Re: [PHP-DEV] Proposal for a new basic function: str_contains

This is only part of a thread. view whole thread
  108647
February 17, 2020 12:08 philipp.tanlak@gmail.com (Philipp Tanlak)
Am Mo., 17. Feb. 2020 um 12:56 Uhr schrieb Nikita Popov <
nikita.ppv@gmail.com>:

> On Mon, Feb 17, 2020 at 12:49 PM Benjamin Morel 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 >
Thanks for the hint Benjamin. I've cited Nikita and added that to the RFC for clarification.