This is specified in Manual: strpos ()
This function can return Boolean FALSE, but it can also return a non-boolean value that evaluates to FALSE, such as 0 or "". Please read the Booleans section for more information. Use the === operator to check the return value of this function.
In your case, the string is at index 0 and in php 0 == false
The solution is to simply use a strict comparator
echo strpos($string,$search) === false ? "not found" : "found";
Other
echo is_int(strpos($string,$search)) ? "found" : "not found";
Or something ... let's say interesting: D For illustration purposes only. I do not recommend this one.
echo strpos('_' . $string,$search)
source share