What’s the difference between those PHP if expressions!?
if ($var !== false)
{
// Do something!
}
if (false !== $var)
{
// Do something!
}
Some frameworks like Zend Framework uses the latest form while the traditional is the first.
Thanks in advance
The result of the expression is the same however it’s a good way of protecting yourself from assigning instead of comparing (e.g writing
if ($var = false)instead ofif ($var == false), since you can’t assign the value$varto thefalsekeyword)