If one has :
$arr = array('a','b','c');
And calls upon the following :
$arr[b] (as opposed to $arr['b'])
Then the following will result :
Warning: Use of undefined constant b - assumed 'b' in ./tmp.php on line 13
Warning: Undefined index: b in ./tmp.php on line 13
Always use quotes around the keys/indexes within associative arrays
otherwise the constant is looked for first and unexpected results are
possible. Now if we have (which you most likely did) :
$arr['d']
Then we get the following as index 'd' does not exist within the array :
Warning: Undefined index: d in ./tmp.php on line 13
A similar error is created when doing this :
echo $iamnotset;
if ($iamnotset) {
Which results in :
Warning: Undefined variable: iamnotset in ./tmp.php on line 11
Using something similar to isset() helps combat that :
if (isset($iamnotset)) {
All of the above errors (Notices) are of the E_NOTICE type. If E_NOTICE
is turned on within the error_reporting setting within php.ini (or via a
call to the error_reporting() function or ...), then you'll see it
otherwise you will not. I'm not sure why Notices say "Warning: ..." but
they do :-)
Typically one turns errors up during development, and down during
production use. And, it's not uncommon to see this question come about
within various support forums/lists for various PHP applications.
Regards,
Philip
> > -----Original Message-----
> > From: Ivo Stoykov [mailto:[EMAIL PROTECTED]]
> > Sent: 11 iulie 2001 17:21
> > To: [EMAIL PROTECTED]
> > Subject: [PHP] Undefined index?
> >
> >
> > Hi everybody
> >
> > Does anybody knows what means "Undefined index" error? I
> > couldn't find it in
> > docs neither in php online doc site.
> >
> > Thank you
> >
> > Ivo
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail:
> > [EMAIL PROTECTED]
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]