Home >Backend Development >PHP Tutorial >About the problem of strpos in PHP_PHP Tutorial
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