How to suppress Undefined index error?

mpen

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.

Niet the Dark Absol

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to suppress "error TS2533: Object is possibly 'null' or 'undefined'"?

From Dev

How to suppress error message of a command?

From Dev

How to suppress OpenCV error message

From Dev

How to suppress QXcbConnection: XCB error

From Dev

How to suppress error messages in zsh?

From Dev

PHP error undefined index

From Dev

Undefined index error in a variable

From Dev

Undefined Index Error in Wordpress

From Dev

Notice: Undefined index: error

From Dev

Undefined index: error in php

From Dev

How does Flight framework avoid undefined index error

From Dev

How to solve 'Undefined Index' Error from <input type="radio">?

From Dev

How to check if a checkbox returns a value? Error:"Notice: Undefined index:"

From Dev

How to counter 'Undefined Index' error when $_GET[''] form is not used?

From Dev

How to suppress "Unsupported parameters" error in Ansible?

From Dev

how to suppress error from .vim plugin vimIM

From Dev

How can I suppress these error messages?

From Dev

How to suppress tar error messages in when piping

From Dev

How to suppress certain error message in 'find' command?

From Dev

How to suppress error in pycharm community edition?

From Dev

Undefined index "order", mapping error?

From Dev

undefined index error with isset() in place?

From Dev

Error : Undefined index - PHP, MySql

From Dev

Error ajax and PHP "Undefined index"

From Dev

undefined index error in login form

From Dev

php Undefined index Error on profile

From Dev

Undefined index "order", mapping error?

From Dev

undefined index error with isset() in place?

From Dev

PHP Error With Form - Undefined index