Re: distinguish between null variable and unset variable
| From: | Carlos Medina | Date: | Thu, 22 Jan 2009 22:07:09 +0000 |
| Subject: | Re: distinguish between null variable and unset variable | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-287034@lists.php.net to get a copy of this message | ||
Shawn McKenzie schrieb:
Daniel Brown wrote:$testvariable1; $testvariable2 = null; $testvariable3 = ''; var_dump($testvariable1); var_dump($testvariable2); var_dump($testvariable3); var_dump( isset( $testvariable1)); var_dump( isset( $testvariable2)); var_dump( isset( $testvariable3)); var_dump( is_null( $testvariable1)); var_dump( is_null( $testvariable2)); var_dump( is_null( $testvariable3)); NULL NULL string(0) "" bool(false) bool(false) bool(true) bool(true) bool(true) bool(false) Regards CarlosOn Thu, Jan 22, 2009 at 15:12, Daniel Brown <danbrown@php.net> wrote:That's why I was testing isset() fist, however as you pointed out, that is crap also. :-(Unfortunately, neither solution would work. isset() will return FALSE even for an instantiated and explicitly-defined NULL variable.Forgot to mention that, in addition, is_null() will return TRUEfor both explicitly-set NULL variables and undefined variables alike.