Home > Article > Backend Development > Analysis of PHP stripos() function and precautions_PHP tutorial
定义和用法
stripos() 函数返回字符串在另一个字符串中第一次出现的位置。
如果没有找到该字符串,则返回 false。
语法
stripos(string,find,start)
参数
描述
string
必需。规定被搜索的字符串。
find
必需。规定要查找的字符。
start
可选。规定开始搜索的位置。
Tips and Notes
Note: This function is not case sensitive. For case-sensitive searches, use the strpos() function.
Since this function returns the position of the first occurrence of a string in another string. So this position may be 0
Then you need to pay attention when the return value is 0
//0 is a exists and $r total, but since 0 and false are equal, so it is executed here
}
if(stripos($r, 'a') === false) {
// In this case we must use all equals
}