As a php neewbie , I try to read a lot of other people´s code in order to learn. Today I came across a line like this :
if ( stripos($post_to_check->post_cont
!==
is a comparison that doesn't only compare the value, but also the type of both variables.
It is used here because stripos
can return false
when no hit was found, but also 0
when a hit was found in the first character of the string.
==
is unable to distinguish those two cases (they are both "falsy"), so you have to use ===
when working with stripos
. There's a warning in the manual:
This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE, such as 0 or "". Please read the section on Booleans for more information. Use the === operator for testing the return value of this function.