Jump to content

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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.