doubledee Posted April 4, 2011 Share Posted April 4, 2011 Is there a better way to say this... if ($_POST['PaRes'] !== '') Is this the same as saying Not IsEmpty() or Not IsNull() Debbie Quote Link to comment Share on other sites More sharing options...
Psycho Posted April 4, 2011 Share Posted April 4, 2011 It really depends on EXACTLY what you are checking for. If you want to ensure the value is not an empty string, then the code you posted is appropriate. The empty() function returns true on several different values. http://php.net/manual/en/function.empty.php Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 4, 2011 Share Posted April 4, 2011 Be carefull with empty, since it can return a false positive if the string being checked contains a single zero: <?php $x = '0'; if (empty($x)) echo "$x is empty<br>\n"; else echo "$x is not empty<br>\n"; ?> The above code will print 0 is empty Ken Quote Link to comment Share on other sites More sharing options...
doubledee Posted April 4, 2011 Author Share Posted April 4, 2011 Be carefull with empty, since it can return a false positive if the string being checked contains a single zero: <?php $x = '0'; if (empty($x)) echo "$x is empty<br>\n"; else echo "$x is not empty<br>\n"; ?> The above code will print 0 is empty Ken Yeah, I read the manual. Looks like I better leave the code As-Is. Thanks, Debbie 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.