Can’t get the point of === and !== with primitive types:
$a === $b TRUE if $a is equal to $b, and they are of the same type.
$a !== $b TRUE if $a is not equal to $b, or they are not of the same type.
The assuming that $request->getMethod() returns GET or POST (as string) and that $form->isValid() returns a boolean true or false, the following code:
if('POST' === $request->getMethod() || (false === $form->isValid())) :
endif;
Does make any sense in respect of this shorter one:
if('POST' == $request->getMethod() || !$form->isValid()) :
endif;
You have truty and falsy values in PHP. For instance,
0,'',array()are falsy values. If you use==it will match those values with the truty/falsy values:===will match not only the value but the type also:This will become a problem when a function can return
0orfalse,strposfor example.There are also other factors with the
==. It will type cast values to aintif you compare 2 different types:This will be problematic if you compare a password: http://phpsadness.com/sad/47