Re: Uninitialized string offset

From: Date: Sat, 06 Jul 2002 21:07:32 +0000
Subject: Re: Uninitialized string offset
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-105879@lists.php.net to get a copy of this message
Thanks for the advice! I understand the problem now. I think they added the Uninitialized string offset in Version 4.1.0 (see <http://www.php.net/ChangeLog-4.php>). That's why I didn't get this warning before. Anyway, I think I'll just add a "@" sign to suppress warnings. I tried it last nights and it works. Uri. -------------------------------------------------------- Richard Lynch wrote: > > >After upgrading to Red Hat Linux 7.3 (which also includes a new PHP > >version), I saw this warning (Uninitialized string offset) on my apache > >error log files. It refers to a line which was perfectly legal before: > > The new settings in php.ini are error_reporting E_ALL by default. > > Those errors have always been there, have always been generated, and you've > been "ignoring" them. > > > if > > >>(isset($GLOBALS['SPEEDY_GLOBAL_VARS']['CURRENT_USER']['UserName'])) > > > >I always use isset to check if a variable is defined. Do you know why I > >get this warning? > > Best Guess: > > PHP is only checking if the *LAST* array reference "isset" -- and to do > that, *has* to assume that the others are there -- IE, that > $GLOBALS['SPEEDY_GLOBAL_VARS']['CURRENT_USER'] is set... > > Change it to this: > > if (isset($GLOBALS['SPEEDY_GLOBAL_VARS'] && > $GLOBALS['SPEEDY_GLOBAL_VARS']['CURRENT_USER'] && > $GLOBALS['SPEEDY_GLOBAL_VARS']['CURRENT_USER']['UserName']){ > > -- > Like Music? http://l-i-e.com/artists.htm --------------------------------------------------------

« previous php.general (#105879) next »