At this piece of code to the top of your PHP script
error_reporting(0);
It’s always better to try and fix the errors than to hide them!!
error_reporting(0);
error_reporting(E_ALL); echo $x;
Notice: Undefined variable: x in [filename] on line [line number]
function exception_error_handler($errno, $errstr, $errfile, $errline ) {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler("exception_error_handler");
Fatal error: Uncaught exception 'ErrorException' with message 'Undefined variable: x' in [filename]:[line number]
Stack trace:
#0 [filename]([line number]): exception_error_handler()
#1 {main}
thrown in [filename] on line [line number]
try {
echo $x;
}
catch(Exception $e) {
}
$current_error_reporting = error_reporting();
if($current_error_reporting & E_NOTICE) {
// do something
}
$old_error_reporting = error_reporting(E_ALL ^ E_NOTICE);
error_reporting($old_error_reporting);
// remove E_NOTICE from error reporting and store previous value $old_error_reporting = error_reporting(error_reporting() ^ E_NOTICE); // run some other code // ... code ... // restore old error reporting level error_reporting($old_error_reporting);
error_reporting(E_ALL); echo error_reporting(), "\n"; $old_error_reporting = error_reporting(error_reporting() ^ E_NOTICE); echo error_reporting(), "\n"; error_reporting($old_error_reporting); echo error_reporting(), "\n";
6143 6135 6143
//$error = error_reporting();
$error = 22527;
$levels = array(
E_ERROR => "E_ERROR",
E_WARNING => "E_WARNING",
E_PARSE => "E_PARSE",
E_NOTICE => "E_NOTICE",
E_CORE_ERROR => "E_CORE_ERROR",
E_CORE_WARNING => "E_CORE_WARNING",
E_COMPILE_ERROR => "E_COMPILE_ERROR",
E_COMPILE_WARNING => "E_COMPILE_WARNING",
E_USER_ERROR => "E_USER_ERROR",
E_USER_WARNING => "E_USER_WARNING",
E_USER_NOTICE => "E_USER_NOTICE",
E_STRICT => "E_STRICT",
E_RECOVERABLE_ERROR => "E_RECOVERABLE_ERROR",
E_DEPRECATED => "E_DEPRECATED",
E_USER_DEPRECATED => "E_USER_DEPRECATED"
);
echo "Report on:\n";
foreach ($levels as $level => $description) {
if ($level & $error) {
echo "$description\n";
}
}
echo "\n";
echo "Do not report on:\n";
foreach ($levels as $level => $description) {
if ($level & ~$error) {
echo "$description\n";
}
}
Report on: E_ERROR E_WARNING E_PARSE E_NOTICE E_CORE_ERROR E_CORE_WARNING E_COMPILE_ERROR E_COMPILE_WARNING E_USER_ERROR E_USER_WARNING E_USER_NOTICE E_RECOVERABLE_ERROR E_USER_DEPRECATED Do not report on: E_STRICT E_DEPRECATED
error_reporting(E_ERROR | E_PARSE);
@someFunctionCall( );
Hello Friends! I am Ramana a part time blogger from Hyderabad.