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() either

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

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

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 wrote: >> Or something like this (dunno, just brainstorming): >> >> function setornull(&$var) >> { >>if (!isset($var)) { >>return false; >>} >>elseif (is_null($var)) { >>retu

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

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 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 Shawn McKenzie
Shawn McKenzie wrote: > Daniel Brown wrote: >> On Wed, Jan 21, 2009 at 20:27, Jack Bates 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 con

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

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

2009-01-21 Thread Lars Torben Wilson
2009/1/21 Daniel Brown : > On Wed, Jan 21, 2009 at 20:27, Jack Bates 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: >

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 wrote: > 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; va

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 Daniel Brown
On Wed, Jan 21, 2009 at 20:27, Jack Bates 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 been assigned the

[PHP] distinguish between null variable and unset variable

2009-01-21 Thread Jack Bates
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() either: k