php_guest Posted February 2, 2011 Share Posted February 2, 2011 Is if($variable) the same as if(!empty($variable)), just different syntax? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted February 2, 2011 Share Posted February 2, 2011 no, they are not the same. http://php.net/manual/en/function.empty.php Quote Link to comment Share on other sites More sharing options...
coupe-r Posted February 2, 2011 Share Posted February 2, 2011 I believe it means if the var ISSET(), but not possitive. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted February 2, 2011 Share Posted February 2, 2011 isset is also not the same as empty http://php.net/manual/en/function.isset.php Quote Link to comment Share on other sites More sharing options...
coupe-r Posted February 2, 2011 Share Posted February 2, 2011 Right, I was referring to if($var) == ISSET($vav), No? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted February 2, 2011 Share Posted February 2, 2011 no i don't think so, at least not if $var is not defined. in which case if ($var) { // will throw an undefined variable notice, and will return NULL if (isset($var)) { // will not throw a notice, and will return a boolean false Quote Link to comment Share on other sites More sharing options...
coupe-r Posted February 2, 2011 Share Posted February 2, 2011 10-4 thanks Quote Link to comment Share on other sites More sharing options...
php_guest Posted February 2, 2011 Author Share Posted February 2, 2011 But in which way are not the same? With values beeing $var=""; $var=0; $var=false; $var="0"; $var=1; $var="string" the following statements output the same if($var)... if(!empty($var))... So in which example would they output different? 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.