This error may appear in two cases:
1. Genuine error
You are getting this error when the code is trying to access a variable or an array element that doesn't exist: either it was never set or just misspelled.
- for a variable, check the previous code where it was supposed to be defined. Verify the spelling (note that variable names are case sensitive) or create this variable if it wasn't.
- for an array element, do a
var_dump($array)and study the output - may be the key was just misspelled (note that array keys are case sensitive so you need to use exactly same case).
In case it is not set at all, check the previous code where the key was supposed to be defined and create an array element with such key.
2. Negligence
This error message is meant to help a PHP programmer to spot a typo or a mistake when accessing a variable (or an array element) that doesn't exist. but in some cases it may appear due to just negligence: since undefined variable is not a fatal error, and it was possible to hide such errors, some programmers tend to just ignore them. But in this case one will lose genuine errors as well, and get undesirable results.
So a good programmer:
Check the good practices listed below: