killboy Posted February 13, 2008 Share Posted February 13, 2008 Is it the same if (!isset($var)) //code and if ($var==null) //code ?????Just wanna know to avoid redundancy in my scripts.Thanks. Link to comment Share on other sites More sharing options...
justsomeguy Posted February 13, 2008 Share Posted February 13, 2008 Those aren't technically the same thing, but isset will return false if the variable is set to null. Link to comment Share on other sites More sharing options...
killboy Posted February 13, 2008 Author Share Posted February 13, 2008 So, I could just write if (!isset($var)) //code Instead if (!isset($var) || $var==null) //code and it would be the same, right? Link to comment Share on other sites More sharing options...
justsomeguy Posted February 13, 2008 Share Posted February 13, 2008 Yeah, you wouldn't need both of them. If the variable is null then isset will return false. Link to comment Share on other sites More sharing options...
killboy Posted February 13, 2008 Author Share Posted February 13, 2008 OK, then. That was the kind of redundancy I was trying to avoid.Thanks. Link to comment Share on other sites More sharing options...
teng84 Posted February 14, 2008 Share Posted February 14, 2008 isset(var) check if set so if var is equal to 0 its trueempty(var) if var is equal to 0 zero truevar = null null means 0 or empty so i think isset is enough but if you want to accept 0 values use empty Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.