After reading How do I check if a string contains a specific word in PHP? and the documentation about strpos()
at http://php.net/manual/en/function.strpos.php, I try an alternative of the first link, instead of !==
, I use >= 0
$a = "Hello";
$b = "a";
if(strpos($a, $b) >= 0) {
echo 'string found';
} else {
echo 'string not found';
}
prints 'string found'
and not 'string not found'
? $b
is obviously not in $a
, so strpos()
should return false
, hence it should enter the else
, what's going on here?