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)) Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.