Php
Types of errors and shielding methods
1.
Note
Notices
)
These are small and not serious errors,
For example, to access a variable that is not defined.
Usually
This type of error is
Not prompt to the user, but sometimes these errors can affect the results of the run.
2.
Warning
Warnings
)
This is a slightly more serious mistake,
For example, to include
Include ()
A file that does not exist itself.
Such a mistake
The information is prompted to the user, but does not cause the program to terminate running.
3.
Fatal Error (
Fatal errors
)
These are serious mistakes,
For example, if you want to initialize an object of a class that doesn't exist,
or call a non-existent
function, these errors can cause the program to stop running,
Php
will also show these errors to the user.
Different types of errors include:
E_error
: It is usually displayed and the program execution is interrupted.
E_warning
: It is usually displayed but does not interrupt the execution of the program.
E_notice
: A code error that occurred while the script was running correctly.
E_parse
: Syntax parsing error.
E_core_error
: In
Php
A fatal error occurred at startup.
E_core_warning
: Reports on
Php
A non-fatal error occurred at startup.
E_compile_error
: A fatal error occurred at compile time, indicating a script error.
E_user_error
: User-generated error message.
E_user_warning
: User-generated warning message.
E_user_notice
: User-raised note message.
E_strict
: Encoding normalization warning, error during run time.
E_recoverable_error
: Near-fatal run-time error, if not captured
E_error
。
E_all
: Captures all errors and warnings.
Shielding
Php
Error hints
Method One: Before a function that is likely to fail, add
@,
And then
Or Die ("")
Such as:
@mysql_connect (...) or Die ("Database Connect Error")
Method Two: Edit
Ini
Find
"Display_errors ="
Will
=
The following value changes to
"Off
。
Method Three: In
Php
Script before adding
Error_reporting (0)
To block all error prompts.
which
Error_reporting
Configure the level of error message return.
Grammar:
int error_reporting (int [level]);
return value: Integer
Function Type:
Php
System functions
PHP error types and Shielding methods