Hi,
On 27 Jul 2004 15:24:48 -0700,
nospam@pedrofonseca.com (Pedro Fonseca)
wrote:
[color=blue]
>Greetings everyone!
>
>I'm porting everything to PHP5. I have session variables in all of my
>web application. Until PHP5 I was using session variables like:
>
>if ($_SESSION['foo'] == 'Bar') {
> $value = 5;
>}
>
>$_SESSION['foo'] is of course set on some other script. But this now
>generates a NOTICE error:
>
>NOTICE: Undefined index: foo in ....... on line ...
>[/color]
I think default error_reporting() has changed. Look up that function.
[color=blue]
>The only way I can think of to get around this (without, of course,
>turning Notices off in the php.ini) is to first use isset on the
>session variable, like this:
>
>if ( isset($_SESSION['foo']) && $_SESSION['foo'] == 'Bar' ) {
> $value = 5;
>}
>
>Is this really necessary?[/color]
I personally find error_reporting very helpful, because it tells you
some of the typos and AFAIK in PHP5 even more of them.
However, you need to use isset everywhere. I think it is worthwhile.
[color=blue]
> Or is there any other way of doing this in
>PHP5? IMHO the whole point of session variables is that they don't
>really have to be defined in one particular script, so why that
>NOTICE?... Do I really need the superfluous call to isset()?[/color]
HTH, Jochen
--
Jochen Daum - Cabletalk Group Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/