JustinK101 Posted September 27, 2006 Share Posted September 27, 2006 Hello all, I have been programming in PHP for a while, but never quite learned the best/effective way to check if a variable is empty?What is the best method to use?if(!isset($var))if($var == null)if($var == "")if(empty($var))if(is_null($var)) Link to comment https://forums.phpfreaks.com/topic/22309-checking-emptynull-variables/ Share on other sites More sharing options...
trq Posted September 27, 2006 Share Posted September 27, 2006 The only way to check if a variable is empty is to use the [url=http://php.net/empty]empty[/url] function. Empty, NULL and set are all different things. Link to comment https://forums.phpfreaks.com/topic/22309-checking-emptynull-variables/#findComment-99920 Share on other sites More sharing options...
JustinK101 Posted September 27, 2006 Author Share Posted September 27, 2006 Yeah most of the time I am checking strings from FORMS, i.e. textfields and pulldown menus. Appears empty() is the one to use. Link to comment https://forums.phpfreaks.com/topic/22309-checking-emptynull-variables/#findComment-99927 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.