Re: Re: 1 last error to fix before the application is done!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Colin Guthrie schreef:
> Jochem Maas wrote:
>> Jason Pruim schreef:
>>> Good morning everyone!
>>>
>>> I think I might be having a "to early in the morning/not enough
>>> caffeine" moment... But I am down to 1 error on my timecard application
>>> that I would like to clean up. It's a small undefined index error, and
>>> the program works jsut fine the way it is, but why leave an error if you
>>> don't need to? :)
>>>
>>> Here is the error:
>>>
>>> [Tue Oct 14 08:19:47 2008] [error] PHP Notice:  Undefined index:
>>> userInfo in
>>> /Volumes/RAIDer/webserver/Documents/dev/stimecard/inc/function/authentication.func.php
>>>
>>> on line 22
>>>
>>> and here is the relevant code:
>>>
>>> ======> Line 22        if($_SESSION['userInfo']['loggedin'] == TRUE) {
>>>            
>>
>> if(isset($_SESSION['userInfo']['loggedin']) &&
>> $_SESSION['userInfo']['loggedin'] == TRUE) {
> 
> Or, seeing as I'm a stickler for compact code:

me too, I also like to be able to change stuff at a single point
in the code so I usually wrap this kind of thing inside a function/class
where I don't have to look at the length of the LOC that does the actual work :-)

...

>   if(!empty($_SESSION['userInfo']['loggedin'])) {

if (Sess::userLoggedIn()) { /* ... :-) */ }

> 
> empty() is like isset() but tests for all sorts of "empty" cases ('',
> false, null and 0 are all considered, "empty").

all true, but just as often you'd want to test for not only a non-empty value
but a very specific value. in which case you'd be back to using isset and a
comparison expression.

> 
> Col
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux