FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » evaluating a null value in an array
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: evaluating a null value in an array [message #173837 is a reply to message #173834] Sat, 07 May 2011 23:46 Go to previous messageGo to previous message
dougatmilmacdotcom is currently offline  dougatmilmacdotcom
Messages: 24
Registered: May 2011
Karma:
Junior Member
In article <iq3scb$gre$2(at)dont-email(dot)me>, Gregor Kofler <usenet(at)gregorkofler(dot)com> wrote:
> Am 2011-05-07 13:36, Jerry Stuckle meinte:
>> On 5/7/2011 7:27 AM, bill wrote:
>>> I have an array of values, one of which might be null.
>>>
>>> This statement fails
>>> if ( ($dos <= $insInfo[3]) or($dos == '0000-00-00'))
>>>
>>> with the error:
>>> Notice: Undefined offset: 3 in /var/www/MP2010-v2/classes/cDollar.php on
>>> line 237
>>>
>>> when $insInfo[3] is NULL.
>>>
>>> I figured I could shortcut the evaluation with:
>>>
>>> if ( ( is_null($insInfo[3])) or($dos <= $insInfo[3]) or($dos ==
>>> '0000-00-00'))
>>>
>>> but I get the same error.
>>>
>>> I sure would appreciate:
>>> knowing why I get the error, and
>>> a suggestion on how to evaluate this value.
>>>
>>> bill
>>
>> Is it null, or is it not set? There is a difference!
>
> Which isset() won't spot.

Nonetheless, isset() is the right function to use here. is_null($x) fails if
$x is not set; isset($x) does not.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Design minisite with minisite master tutorial
Next Topic: getting only the temperature & general weather condition
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 10 02:11:19 GMT 2024

Total time taken to generate the page: 0.04423 seconds