<?php // error_reporting(E_ALL | E_STRICT); // ini_set('display_errors', 'On'); // require 'errors.php';
<?php echo " . <br>"; /* * ( set_error_handler()) */ // NONFATAL - E_NOTICE // echo $undefined_var; // NONFATAL - E_WARNING // array_key_exists('key', NULL); // NONFATAL - E_DEPRECATED split('[/.-]', "12/21/2012"); // split() deprecated php 5.3.0 // NONFATAL - E_STRICT // class c {function f(){}} c::f(); // NONFATAL - E_USER_DEPRECATED // trigger_error("E_USER_DEPRECATED", E_USER_DEPRECATED); // NONFATAL - E_USER_WARNING // trigger_error("E_USER_WARNING", E_USER_WARNING); // NONFATAL - E_USER_NOTICE // trigger_error("E_USER_NOTICE", E_USER_NOTICE); // FATAL, set_error_handler - E_RECOVERABLE_ERROR // class b {function f(int $a){}} $b = new b; $b->f(NULL); // FATAL, set_error_handler - E_USER_ERROR // trigger_error("E_USER_ERROR", E_USER_ERROR); /* * ( set_error_handler()) */ // FATAL - E_ERROR // undefined_function(); // FATAL - E_PARSE // parse_error // FATAL - E_COMPILE_ERROR // $var[]; echo " . <br>";
Error group | Directive Values * | Server response status | Answer to customer ** |
---|---|---|---|
E_PARSE, E_COMPILE_ERROR *** | display_errors = off error_reporting = ANY | 500 | Empty value |
display_errors = on error_reporting = ANY | 200 | Error message | |
E_USER_ERROR, E_ERROR, E_RECOVERABLE_ERROR | display_errors = off error_reporting = ANY | 500 | Script output before error |
display_errors = on error_reporting = ANY | 200 | Error message and script output before error | |
Not fatal errors | display_errors = off error_reporting = ANY and display_errors = on error_reporting = 0 | 200 | All script output |
display_errors = on error_reporting = E_ALL | E_STRICT | 200 | Error message and all script output |
"missing_file.php";
, then the error will fall into the second group. <?php /** * * @param int $errno * @param string $errstr * @param string $errfile , * @param int $errline , * @return boolean */ function error_handler($errno, $errstr, $errfile, $errline) { // ( "@" error_reporting() 0) if (error_reporting() & $errno) { $errors = 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 "<b>{$errors[$errno]}</b>[$errno] $errstr ($errfile $errline )<br />\n"; } // PHP return TRUE; } /** * */ function fatal_error_handler() { // if ($error = error_get_last() AND $error['type'] & ( E_ERROR | E_PARSE | E_COMPILE_ERROR | E_CORE_ERROR)) { // ( ) ob_end_clean(); // error_handler($error['type'], $error['message'], $error['file'], $error['line']); } else { // () ob_end_flush(); } } // error_reporting(E_ALL | E_STRICT); // ini_set('display_errors', 'On'); // ( ) ob_start(); // set_error_handler("error_handler"); // , (, ) register_shutdown_function('fatal_error_handler'); require 'errors.php';
Source: https://habr.com/ru/post/161483/
All Articles