389,534 Members | 6,127 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 389,534 IT Pros & Developers. It's quick & easy.

What is an undefined offset? An undefined index?

lawrence
P: n/a
I just switched error_reporting to ALL so I could debug my site. I got
a huge page full of errors. One of the most common was that in my
arrays I'm using undefined offsets and indexes. These still work fine,
but with error reporting at all they are marked as errors. Why? What
am I doing wrong?

www.monkeyclaus.org
Jul 16 '05 #1
Share this Question
Share on Google+
1 Reply


CC Zona
P: n/a
In article <da7e68e8.0307121026.2559e8c5@posting.google.com >,
lkrubner@geocities.com (lawrence) wrote:
I just switched error_reporting to ALL so I could debug my site. I got
a huge page full of errors. One of the most common was that in my
arrays I'm using undefined offsets and indexes. These still work fine,
but with error reporting at all they are marked as errors. Why? What
am I doing wrong?


It means you're referring to an array key that doesn't exist. "Offset"
refers to the integer key of a numeric array, and "index" refers to the
string key of an associative array.

$s_arr=array("apple", "banana");
print $s_arr[2]; //undefined offset

$a_arr=array("fruit"=>"apple", "meat"=>"beef");
print $a_arr['produce']; //undefined index

--
CC
Jul 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.