Re: Uninitialized string offset
| From: | Richard Lynch | Date: | Sat, 06 Jul 2002 03:42:49 +0000 |
| Subject: | Re: Uninitialized string offset | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-105815@lists.php.net to get a copy of this message | ||
>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