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:58] philipptarfc:str_contains [2020/02/17 12:01] 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>
  
Line 42: Line 46:
 In a recent discussion in the internals mailing list, we came to the conclusion, there is no need for a multibyte variant of this function (e.g. ''mb_str_contains''). The reason behind this is: A multibyte variant of this function would behave no different than the non-multibyte function. Multibyte variants behave differently when the offset/position has relevance at which the string was found. As this is not the case for this function, there is no need for that. In a recent discussion in the internals mailing list, we came to the conclusion, there is no need for a multibyte variant of this function (e.g. ''mb_str_contains''). The reason behind this is: A multibyte variant of this function would behave no different than the non-multibyte function. Multibyte variants behave differently when the offset/position has relevance at which the string was found. As this is not the case for this function, there is no need for that.
  
-Concerning the case-insensitivity for this function: This might be a feature for the future, as the relevance for that is much less compared to the case-sensitive function. With that in mind, the only valid variants would be str_contains/mb_str_icontains. I assume PHP developers would be confused if this RFC offered such inconsistant variants of this function, so it's better to start small and iterate upon that. +Concerning the case-insensitivity for this function: This might be a feature for the future, as the relevance for that is much less compared to the case-sensitive function. With that in mind, the only valid variants would be str_contains/mb_str_icontains. I assume PHP developers would be confused if this RFC offered such inconsistent variants of this function, so it's better to start small and iterate upon that. 
  
 ===== Backward Incompatible Changes ===== ===== Backward Incompatible Changes =====
rfc/str_contains.txt · Last modified: 2020/08/01 23:41 by carusogabriel