Jump to content

Check to see if value is NULL


Allen4172

Recommended Posts

I've tried a couple of things and can't seem to get it to work properly.

I'm attempting to check if a value is NULL. I've tried things like:

[code]

if($variable$ == NULL) {
   $php_var = 0;}
[/code]

The variable isn't from PHP, its from a CMS system, that uses its variables as $something$. With this system, if nothing is typed in, its just blank spaces and the php would see:

[code]
if(     == NULL){
   $php_var = 0;}

[/code]

I'm trying to make it to where, if nothing was entered in, and the script sees the blank, then it would auto put it as 0. Any help or ideas would be appreciated. :)
Link to comment
https://forums.phpfreaks.com/topic/9967-check-to-see-if-value-is-null/
Share on other sites

[!--quoteo(post=375438:date=May 19 2006, 11:24 PM:name=Dave K.)--][div class=\'quotetop\']QUOTE(Dave K. @ May 19 2006, 11:24 PM) [snapback]375438[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[code]
$var = '$variable$';
if (strlen($var) == 0)
{
    $var = 0;
}
[/code]
[/quote]

Thanks Dave, that is exactly what I needed and it now works :) I tried something similar earlier, but I didn't put the single quotes around $variable$ from above.

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.