Use is_null rather than == null

While playing with strings one should be VERY VERY VERY cautious when trying to check for a “null” value

PHP has the bad habit of considering empty strings to be “null” and “false” , for instance

1
2
3
4
$foo = '';
if( $foo == null && $foo == false ){
    echo "So PHP actually considers empty strings to be null and false";
}

(more…)