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()
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
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
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;
}
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
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)) {
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
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,
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
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 ===
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
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
12 matches
Mail list logo