Analysis of PHP stripos() function and precautions_PHP tutorial

WBOY
Release: 2016-07-21 15:07:26
Original
1021 people have browsed it

定义和用法
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

Copy the code The code is as follows:

if(stripos($r, 'a') == false) {

                                             //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

}


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327548.htmlTechArticleDefinition and usage The stripos() function returns the position of the first occurrence of a string in another string. If the string is not found, returns false. Syntax stripos(string,find,st...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!