There are three error reports in PHP:
1. Error, parsing error, fatal error
2. Warning
3. Note
Fatal error, error, will terminate the execution of the program, syntax error, PHP did not execute
Warning, he will not terminate the operation, but will affect the result
Note-* Does not terminate execution and does not affect results
In order for the user to get a better experience, we block out all the wrong output, which is the output, not the display
But in this case, the administrator can not see the error.
Errors are not displayed on the page, and errors are generated with a log that is provided to the administrator for viewing.
Error_reporting (~e_all) shielded all output, and naturally, the administrator could not see the
I don't want to block all the output, I just block all the display
Ini_set (' display_errors ', ' off '); indicates that all errors on the page are masked, but there is no error blocking the output
Ini_set (' Log_errors ', ' on '); // Turn on log write function Ini_set // where the logs are stored Ini_set (' display_errors ', ' off '); // Shielded page Display error_reporting (e_all); // Output All Errors
echo 123; Echo $str; // This will show a note indicating that the variable is not declared Echo Date (); // warning, no reference Echo Dae (); // fatal error, unable to find this function Echo 123;
Abnormal:
in Phpjava
throws an exception, which is One of the reasons why the exception handling statements are rarely seen in PHP source code.
<? PHP // if PHP has built-in exception classes that handle dividend cannot be zero, then it is not necessary to manually throw the $a = 5; $b = 0; Try { echo$a$bcatch (Exception$ E) { echo ' found abnormal '; } // In this case, the capture statement is not executed, and the error message is still displayed on the page: Warning:division by Zero
<?PHP//PHP cannot automatically throw exceptions, so we need to throw them manually$a= 5;$b= 0;Try { if($b= = 0)Throw New Exception(' Divisor is zero '); Echo $a/$b;} Catch(Exception $e) { Echo' Produce an exception: '.$e-getMessage ();}
page Output: generates an exception: the divisor is zero
PHP Error and exception handling