Re: [PHP] distinguish between null variable and unset variable

2009-01-23 Thread Thodoris
How can I tell the difference between a variable whose value is null and a variable which is not set? // cannot use === null: ket% php -r '$null = null; var_dump(null === $null);' bool(true) ket% php -r 'var_dump(null === $unset);' bool(true) ket% // - cannot use isset()

Re: [PHP] distinguish between null variable and unset variable

2009-01-22 Thread Shawn McKenzie
Daniel Brown wrote: On Wed, Jan 21, 2009 at 20:27, Jack Bates ms...@freezone.co.uk wrote: How can I tell the difference between a variable whose value is null and a variable which is not set? Unfortunately, in PHP - like other languages - you can't. A variable is considered to be

Re: [PHP] distinguish between null variable and unset variable

2009-01-22 Thread Shawn McKenzie
Shawn McKenzie wrote: Daniel Brown wrote: On Wed, Jan 21, 2009 at 20:27, Jack Bates ms...@freezone.co.uk wrote: How can I tell the difference between a variable whose value is null and a variable which is not set? Unfortunately, in PHP - like other languages - you can't. A variable

Re: [PHP] distinguish between null variable and unset variable

2009-01-22 Thread Daniel Brown
On Thu, Jan 22, 2009 at 15:11, Shawn McKenzie nos...@mckenzies.net wrote: Or something like this (dunno, just brainstorming): function setornull($var) { if (!isset($var)) { return false; } elseif (is_null($var)) { return null; }

Re: [PHP] distinguish between null variable and unset variable

2009-01-22 Thread Daniel Brown
On Thu, Jan 22, 2009 at 15:12, Daniel Brown danbr...@php.net 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

Re: [PHP] distinguish between null variable and unset variable

2009-01-22 Thread Shawn McKenzie
Daniel Brown wrote: On Thu, Jan 22, 2009 at 15:11, Shawn McKenzie nos...@mckenzies.net wrote: Or something like this (dunno, just brainstorming): function setornull($var) { if (!isset($var)) { return false; } elseif (is_null($var)) {

Re: [PHP] distinguish between null variable and unset variable

2009-01-22 Thread Shawn McKenzie
Daniel Brown wrote: On Thu, Jan 22, 2009 at 15:12, Daniel Brown danbr...@php.net 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

Re: [PHP] distinguish between null variable and unset variable

2009-01-22 Thread Carlos Medina
Shawn McKenzie schrieb: Daniel Brown wrote: On Thu, Jan 22, 2009 at 15:12, Daniel Brown danbr...@php.net 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,

Re: [PHP] distinguish between null variable and unset variable

2009-01-21 Thread Daniel Brown
On Wed, Jan 21, 2009 at 20:27, Jack Bates ms...@freezone.co.uk wrote: How can I tell the difference between a variable whose value is null and a variable which is not set? Unfortunately, in PHP - like other languages - you can't. A variable is considered to be null if: * it has

Re: [PHP] distinguish between null variable and unset variable

2009-01-21 Thread Paul M Foster
On Wed, Jan 21, 2009 at 05:27:35PM -0800, Jack Bates wrote: How can I tell the difference between a variable whose value is null and a variable which is not set? // cannot use === null: ket% php -r '$null = null; var_dump(null === $null);' bool(true) ket% php -r 'var_dump(null ===

Re: [PHP] distinguish between null variable and unset variable

2009-01-21 Thread Alexandre Gaigalas
On Thu, Jan 22, 2009 at 12:21 AM, Paul M Foster pa...@quillandmouse.comwrote: On Wed, Jan 21, 2009 at 05:27:35PM -0800, Jack Bates wrote: How can I tell the difference between a variable whose value is null and a variable which is not set? // cannot use === null: ket% php -r '$null

Re: [PHP] distinguish between null variable and unset variable

2009-01-21 Thread Lars Torben Wilson
2009/1/21 Daniel Brown danbr...@php.net: On Wed, Jan 21, 2009 at 20:27, Jack Bates ms...@freezone.co.uk wrote: How can I tell the difference between a variable whose value is null and a variable which is not set? Unfortunately, in PHP - like other languages - you can't. A variable is