What are some common mistakes made when using strpos in PHP?

One common mistake when using strpos in PHP is forgetting to check for strict comparison (===) in the condition, which can lead to unexpected results if the substring is found at the beginning of the string. To solve this issue, always use strict comparison to ensure the correct position is returned.

// Incorrect way without strict comparison
$pos = strpos($haystack, $needle);
if ($pos) {
    // Do something
}

// Correct way with strict comparison
$pos = strpos($haystack, $needle);
if ($pos !== false) {
    // Do something
}