Jump to content

Recommended Posts

There's a table in the documentation that shows what is considered to be 'empty' - http://php.net/manual/en/types.comparisons.php

 

You could also just test each of those values using some code to see for yourself.

Hi there Vijdev,

$variable=""; //Setting var as empty or setting it for later, quotes mean string
$variable=0//numerical value or can be boolean
$variable=NULL//Same as the top one, but useful for passing into functions as an optional paramter

 

and

and which of the above will satisfy

if(empty($variable))

{

echo "blah!";

}

 

The top one, and if nothing is sent into the last one, that can be construed as empty/not set.  Bearing in mind that isset() and empty() have similar uses - BUT empty checks to see if there is any value in the variable, this is useful to check session/cookie data etc.

 

Hope that helps a little.

 

Cheers,

Rw

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.