From the course: PHP for Web Designers

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

What does undefined index, variable, or constant mean?

What does undefined index, variable, or constant mean? - PHP Tutorial

From the course: PHP for Web Designers

Start my 1-month free trial

What does undefined index, variable, or constant mean?

The error message omits the dollar sign, and it tells us the problem is on line 56. And the Undefined index is also on line 56, so that indicates that the two might actually be related. So let's have a look at the code in our Editing program. Scroll down to line 56. And there, on line 56, using features within square brackets, season, with an upper case S. And if we go a little bit further up in the page, We can see that on line 34, season is defined with a lower case S. So that's the problem, it's case sensitivity. PHP variables are case sensitive. This was with a lower case S. If you try to use it with an uppercase S, PHP regards it as a completely different variable. So, if we change that, and save the page. Go back to the browser, and reload the page. Both problems disappear. And the reason for that, is that season was the array key for features. And the word index is just another name for an array key. We can test that by changing this variable to a string. So let's change it to…

Contents