On Thu, 2003-08-14 at 19:27, Zeev Suraski wrote: > At 21:15 14/08/2003, walt boring wrote: > > The way PHP treats null value is identical to that of non existent values, > which is precisely why isset() behaves the way that it does. I'm not sure > what the logic is behind Ilia's alternatives, they won't behave any > differently whether $var exists and is null, or whether it doesn't exist at > all, and it's intentional. > > Zeev
Sorry to possibly riding in late on this but my power was out for a couple of days :) Anyways, if PHP treats the null value identical to that of non-existent value then why does the following not generate a warning? $foo = null; echo $foo; whereas a non-existent value does produce an warning: echo $fee; I think the issue here is that because PHP allows developers to use the null value as any other literal value, that it has been used in this way, and not as you might have originally hoped. Thus null is a valid value and for many developers (myself included) it doesn't not simply represent the non-existence of a value. Also to exascerbate the problem further, if setting a value to null is the same as unsetting the value, then why do I get the following odd behaviour? $foo = array( 1, 2, 3, 4, 5 ); $foo[2] = null; foreach( $foo as $key => $value ) { echo $key.' -> '.$value."\n"; } Output: 0 -> 1 1 -> 2 2 -> 3 -> 4 4 -> 5 So it seems to me that a null value does not define the non-existence of a value, but is itself actually a value. And this as far as I am concerned is quite valid. Cheers, Rob. -- .---------------------------------------------. | Worlds of Carnage - http://www.wocmud.org | :---------------------------------------------: | Come visit a world of myth and legend where | | fantastical creatures come to life and the | | stuff of nightmares grasp for your soul. | `---------------------------------------------' -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php