rfc:str_contains

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
rfc:str_contains [2020/02/17 11:59] philipptarfc:str_contains [2020/02/17 12:08] philippta
Line 35: Line 35:
 str_contains("abc", "a"); // true str_contains("abc", "a"); // true
 str_contains("abc", "d"); // false str_contains("abc", "d"); // false
 +
 +// $needle is an empty string
 +str_contains("abc", "");  // true
 +str_contains("", "");     // true
 </code> </code>
 +
 +Regarding empty string values as $needle:
 +<blockquote>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. - Nikita Popov</blockquote>
  
  
rfc/str_contains.txt · Last modified: 2020/08/01 23:41 by carusogabriel