When E_NOTICE is set to on, PHP will report undefined index for arrays. I want to suppress this error for $_GET
only. Is there any way to do that other than prepend
If you don't want to modify all the $_GET references in your code, you could create your own error handler to PHP, by using set_error_handler
function
Example (completely untested, but shows the idea):
function myErrHandler ($errno, $errstr, $errfile, $errline) {
if(strstr("GET", $errstr)) {
// suppress message
return true;
}
// otherwise, continue with PHP internal error handler
return false;
}
set_error_handler("myErrHandler", E_NOTICE);