Re: wrong implementation of isset()?

From: Date: Wed, 07 Feb 2001 21:26:17 +0000
Subject: Re: wrong implementation of isset()?
References: 1 2 3  Groups: php.dev 
Request: Send a blank email to php-dev+get-45987@lists.php.net to get a copy of this message
At 03:02 AM 2/7/2001 +0100, Cynic wrote:
with all respect to the people who develop the language, I think this is nonsense: $rs = mysql_query( 'select x, y, z from foo where ...' ) ; $x = mysql_fetch_array( $rs , MYSQL_NUM ) ; var_dump( $x[2] ) ; var_dump( isset( $x[2] ) ) ; NULL # well, the column contains null values bool(false) But since (almost) everybody else disagrees, I must be missing something obvious. BTW, does $x = null really equal to unset( $x ) or does isset() just get fooled by its value?
unset() removes it from the symbol table and $x = NULL; changes it to be a NULL value. As far as PHP scripts are concerned it's pretty much the same thing. There are certain situations where you can't really nuke the variable but you want to mark it as dead. In any case, you can always use the === operator to check if something is really NULL and not false. if ($x === NULL) { } I can't remember off hand all the reasons for isset(NULL) being false but the main reason is that it makes a lot of sense because what the NULL value is supposed to mean is that there's no value. Also it allows us to differentiate between functions returning bool(false) and null values. Hence also the === operator. I really think that if your script differentiates between these two cases you might not be writing it very well. OK, I know it's a messy Email. I'm on the way to bed but I hope it clarifies a few things :) Andi

« previous php.dev (#45987) next »