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
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
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
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
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
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;
>}
>
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
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:
>
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:
>
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
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 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
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
13 matches
Mail list logo