Re: Function Misbehaving

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Beginners beware ... small, potential head-fryer coming up...

Richard Lynch wrote:
> I personally would use is_null($url) to test if it was NULL.
> 
> isset() is not the weapon of choice for that, imho...
> 
> No idea if that will "fix it" as I've never tried to use isset() to
> test for NULL and have no idea what it does.


occasionally we need to eat our own dogfood Richard (i.e. test stuff) :-) ...

php -r '$a = null; $b = array(null); var_dump(isset($a), isset($b[0]));'

which is not helpful to the beginner because setting $a to NULL means $a is not set,
counter-intuitive to say the least :-) but we both know this is not going to change.

BUT even when it's not set it kind of is ...

php -r '
error_reporting(E_ALL);
$a = null; var_dump(isset($a), $a);
var_dump(isset($b), $b);
'

niether $a nor $b are set but $a is still more set than $b. are you confused? :-)
I guess is_null() is the weapon of choice here!

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux