Daniel Brown wrote:
> On Wed, Jan 21, 2009 at 20:27, Jack Bates <ms...@freezone.co.uk> wrote:
>> How can I tell the difference between a variable whose value is null and
>> a variable which is not set?
> 
>     Unfortunately, in PHP - like other languages - you can't.
> 
>     A variable is considered to be null if:
>         * it has been assigned the constant NULL.
>         * it has not been set to any value yet.
>         * it has been unset().
> 

I'm not in a position to test right now, but using Dan's logic I would
turn it around and test for isset first and then is_null.  This makes
sense to me, but maybe it is flawed:

if (isset($var) && is_null($var)) {
        echo "$var is set and is null";
}

Or maybe a function to return is the $var === null:


function eq_null(&$var)
{
        return (isset($var) && is_null($var)) ? true : false;
}

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to