First, the wrong classification
Syntax error:
The program can not run, directly prompt syntax error.
Run-time error:
Errors that occur only if the program runs to a row, or is run in certain specific situations.
Logic error:
The program runs from start to finish without (and prompting) errors, but the results of the program run calculation are incorrect.
The main thing we programmers face and the error to deal with is a run-time error.
Second, the wrong grading
System error:
E_error: System Critical Error
Once it happens, the program stops executing immediately.
This error is generally expected immediately.
E_warning: System Warning
One occurs, prompts for errors, and continues execution.
Usually this error is expected to be dealt with "next business Day" (resolution).
E_parse: Syntax error
Occurs, prompts for errors, and the code does not run at all-check the syntax before running.
E_notice: System Tips
One occurs, prompts for errors, and continues execution.
Send an e-mail notice, your own schedule time to solve.
Third, user-defined error
There are only 3 of them:
E_user_error;
e_user_warning;
E_user_notice;
We can create (generate) errors ourselves in the program--errors created to address some of the data's unreasonable circumstances.
For example: Let the user fill in the age, fill 18 is OK, but fill 188 is unreasonable-from the digital angle itself is no problem.
Other:
E_all; represents all errors--indicates that it can "include" errors.
E_strict: Represents a "strict" syntax check error-a syntax that can be executed, but is not welcome in the current PHP version.
Four, the wrong trigger:
1. Normal Trigger:
A run-time error did occur while the program was running--it could also be a syntax check error.
2, Manual trigger:
Is that the programmer "generates" an error by means of the program code.
Application, it is usually necessary to detect (judge) the validity of the data to determine whether to trigger the corresponding error
V. Incorrect Display control
Web page display (hint) error message, can be controlled, there are 2 ways:
1, in PHP. INI file, which is valid for all PHP programs;
2, in the current script file, only valid for the current Footstep file.
The error display has 2 aspects which can be controlled;
1, set whether to display: Display_error:
2, set what level of error is displayed-dependent on the condition that the first item is set to display.
Vi. Logging of error logs
There are 2 ways to log error logs:
1, set in the php.ini file:
Visible, the error message displayed on the page, and the contents of the error messages recorded in the log file.
Error_log also has a special value that can be used:
Error_log = syslog;//The error log file is not logged at this time, but the error message is written to the system error log
2, in the current script file:
Ini_set ("Log_errors", on);//or Off
Ini_set ("Error_log", ' err1.log ');//suffix whatever
Ini_set ("Error_log", ' err2.txt ');
Ini_set ("Error_log", ' err3.html ');
Int_set ("Error_log", syslog);//logging to the operating system log.
Custom error Handling
The above error handling, whether displaying errors or logging error logs, is implemented within the PHP language.
We are just a few simple settings for whether to display or whether to record or show which, or where to record.
The
Custom error handling, you can let us completely control the wrong prompt content!
The procedure is very simple:
1. Set the name of the custom function to be used for custom processing errors;
2. Define the function yourself and output (or record) any error messages in it.
Once these two things are done, once an error occurs, the system calls the function to execute the code inside--What do you want to do?
PHP Knowledge points-Error handling