Jump to content

Another way to say this? (!=='')


doubledee

Recommended Posts

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

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

 

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.