I'm finding a glitch in using strpos() to test whether a substring exists in a string, when the following is true:
$string = 'this is my string';
if ( strpos($string, 'this' )
{ echo "substring exists"; }
else
{ echo "substring doesn't exist"; }
Since strpos = 0 in this case (because 'this' starts at the 0th character of $string), the condition goes to false: 'substring doesn't exist'
Is this not the way to use strpos? Or must I code it like this:
if ( strpos($string, 'this' ) >= 0 )