I have inherited a project from another developer, and it is riddled through and through with the following type of error:
echo $data['example'];
Notice: Undefined index: example
Obviously, I'm going to refactor this to check for the existence of the key prior to the print statement. However, my question is not related to the code per-se.
Is there a version of PHP, or perhaps a setting within PHP whereby echo $data['example'];
would simply return null or 0 in the case of a non-existent key?
I ask because I'm trying to ascertain whether the previous developer had written bad code, or whether their development environment is misconfigured. If it's the latter, we can obviously resolve these issues for that developer's future projects.
null
, and ignoring notices is about as bad an advice as it gets. If your code is riddled with notices like this, advising to silence them is like suggesting to a hoarder to cram all his stuff under the carpet. It doesn't solve the problem.