Currently whenever i am trying to determine when a variable is not defined i use the code
if($variable==””)
however i have been told by people to use the function
if(empty($variable))
Reading on this, it returns false if the value is 0, and i have plenty of array values that are zero that cant be returning false. i could always add ||$variable==0) to skip this.
But all i am asking is why is this a preferred method for determining empty variables, is it efficiency or is there more to it than that?
If you need to know, use strict type comparison:
Generally, you should use
isset()– if the variable hasn’t yet been defined, it returns false: