Is there a case where doing this?
if(!$array) {
//... do stuff
}
Would produce different results than this?
if(empty($array)){
//... do stuff
}
答案 0 :(得分:0)
As I found out on the PHP docs, empty() is actually equivalent to !isset($var) || $var == false
.
In other words, if(!$array)
and if(empty($array)
would return the same value unless the $array is not set, in which the first piece of code would return an Exception