Analysis of PHP stripos of functions and precautions

  • 2020-06-12 08:37:46
  • OfStack

Definition and usage
The stripos() function returns the position of the first occurrence of a string in another string.

If the string is not found, false is returned.

grammar
stripos(string,find,start)
parameter describe string A necessity. Specifies the string to be searched for. find A necessity. Specifies the character to look for. start Optional. Specify where to start the search.

Hints and comments
Note: This function is case insensitive. For a case-sensitive search, use the strpos() function.
Because this function returns the position of the first occurrence of the return string in another string. So this position could be 0
So you have to be careful when the return value is 0


if(stripos($r, 'a') == false) {
       //0 is a Existence and $r But as a result of 0 and false It's going to be the same, so it's going to be executed here 
}
if(stripos($r, 'a') === false) {
     //  In this case we have to use all equals 
}


Related articles: