Home  >  Article  >  Backend Development  >  About the problem of strpos in PHP_PHP Tutorial

About the problem of strpos in PHP_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 17:54:301625browse

strpos is used to find one or more strings in a string
Code:
$str1='ext-gen1226';
$str2='ext';
//echo strpos($str1,str2,0);
if(strpos($str1,str2,0)==false){

echo'AAA';
}else{
echo'BBB';
}
Result: AAA
Normally, the output should be BBB. This is because str2 is at the first position of str1. As a result, strpos returns 0, and the value defaults to false. We use double equal signs to judge, so we return AAA;
$a == $b equals TRUE if $a equals $b.
$a === $b Congruent TRUE if $a is equal to $b and they are of the same type. (Introduced in PHP 4, so change it to three equal signs to judge

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477953.htmlTechArticlestrpos is used to find one or more string codes in a string: $str1=ext- gen1226; $str2=ext; //echo strpos($str1,str2,0); if(strpos($str1,str2,0)==false){ echoAAA;...
Statement:
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