RE: [PHP] Something difference betwen php-4.0.3 and php-4.2.3
| From: | Ford, Mike [LSS] | Date: | Fri, 24 Jan 2003 11:14:36 +0000 |
| Subject: | RE: [PHP] Something difference betwen php-4.0.3 and php-4.2.3 | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-132966@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Chris Hewitt [mailto:g0pae@manordat.demon.co.uk]
> Sent: 24 January 2003 09:13
>
> andre.lagadec@education.gouv.fr wrote:
>
> >I modifiy my php.ini to redirect error message in log of
> server web and I change
> >error_reporting = E_ALL & ~E_NOTICE by error_reporting = E_ALL
> >
> >Now, I get in server log this message :
> >[24-Jan-2003 08:59:31] PHP Notice: Undefined offset: 4 in
> /appli/PHP/test/__xyz__.php on
> >line 15
> >and I get all code HTML : the program doesn't fail !
> >
> That is working correctly, it is what should happen. You changed your
> error reporting to include "notices". These are not errors
> but warnings
> to tell you that you _may_ have something not right.
Correct.
>
> In this case, an undefined offset means that the variable you used in
> the offset has not been previously set a value, so:
> $myarray[$myoffset];
> will produce this error if $myoffset has not already been set
> a value.
> If you do:
> $myoffset = 4;
> $myarray[$myoffset];
> then you should not get the warning.
Wrong. The offset is 4, the error message says so. Undefined offset means you are trying to access
a character from a string that doesn't exist -- in this case, the 5th character of a string
that is shorter than 5 characters. (If $myoffset was undefined, you'd get an undefined
variable warning.)
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211