Re: distinguish between null variable and unset variable

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

 



Shawn McKenzie schrieb:
Daniel Brown wrote:
On Thu, Jan 22, 2009 at 15:12, Daniel Brown <danbrown@xxxxxxx> wrote:
   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 TRUE
for both explicitly-set NULL variables and undefined variables alike.


That's why I was testing isset() fist, however as you pointed out, that
is crap also.  :-(


  $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

Carlos

--
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