Reputation: 282825
Before you suggest using isset
or empty
or array_key_exists
-- I know.
I've inherited an old project with close to a million lines of code. I would like to enable E_NOTICE
but I get flooded with messages. As a temporary solution I've suppressed just "undefined index" errors by doing this:
function _global_error_handler($level, $message, $filename, $line_no, $context) {
if($level===E_NOTICE && substr($message,0,16)==='Undefined index:') return false;
But I was hoping there would be some way to disable the notice altogether via an INI setting or something. I don't want the overhead of it calling the global error handler every time this happens.
Upvotes: 1
Views: 1705
Reputation: 324620
No, there is no way to be more specific than the E_*
constants, short of manually parsing the error condition as you currently are doing.
What I would suggest for now is to disable E_NOTICE
errors. When you have the opportunity (which should be as soon as reasonably possible), enable them again and go through fixing as many as possible.
Upvotes: 2