1. Common types of errors in PHP
1. Syntax Errors
* 1). Write fewer semicolons
* 2). 。 。。。。。
2. Environmental Errors
* 1). PHP Configuration Wait
3. Logic Error
* 1). To use an equal sign, the result uses two equal signs
2. Defined error types
Error name |
Error Description |
E_ALL |
All errors and Reports |
E_ERROR |
Fatal run-time error, the execution of the script is |
E_WARBING |
Run-time warning (non-fatal), execution of script is not paused |
E_PARSE |
Compile-Time Parse error |
E_NOTICE |
Run-time Reminders |
E_STRICT |
Start PHP recommendations for code modifications to ensure optimal interoperability and forward compatibility of your code |
E_DEPRECATED |
runtime notifications, which will warn you about code that might not work in a future release |
E_CORE_ERROR |
Fatal error occurred during initialization of PHP startup |
E_CORE_WARNING |
A warning error (non-fatal) that occurred during initialization during PHP startup |
E_COMPILE_ERROR |
Compile-time fatal error |
E_COMILE_WARNING |
Compile-time warning (non-fatal error) |
E_USER_ERROR |
User-generated error messages |
E_USER_WARNING |
User-generated warning message |
E_USER_NOTICE |
User-generated reminder messages |
E_USER_DEPRECATED |
User-generated warning message, similar to e_deprecated, but generated by a trigger_error function |
E_RECOVERABLE_ERROR |
Can be caught indicating an error, she said that a very dangerous error may have occurred, but has not caused the PHP engine to be in an unstable state. If the error is not captured by the user's custom handle (see set_error_handler() ), it becomes a e_error, and the script terminates. |
Error level in 3.php
1. Deprecated(不推荐|过时)
Error
* 1). 最低级的错误
For example ereg
, using a function, mysql_escape_string
* 2).Deprecated: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead.
2. Notice
Notification-level errors
* 1). To access undefined variables
* 2). When accessing an array, $arr ["name"]; The program first executes the lookup constant name, and if not found, the name is treated as a string
3. Warning
Warning Level errors
* 1). Wrong number of parameters
* 2). Wrong parameter type
4. Fatal error
fatal level of error (终止程序继续执行)
* 1). Invoke undefined function
* 2). Wrong parameter type
5. parse error
Parsing Errors
* 1). The inspection phase did not pass, no other errors will be seen, because not yet where,程序还没解析成功
6. E_USER_相关的错误
* 1). The inspection phase did not pass, no other errors will be seen, because not yet where,程序还没解析成功
4. Error-related options in the PHP configuration file
Options |
Description |
Error_reporting |
Set the level of error reporting |
Display_error |
Whether an error is displayed |
Log_errors |
Sets whether the resulting error message is logged or Error_log |
Error_log |
To set the save file for the error log |
Log_errors_max_len |
Set the maximum number of bytes for log_errors |
Ignore_repeated_errors |
Whether to ignore duplicate error messages |
Ignore_repeated_source |
Whether to ignore duplicate message sources |
Track_errors |
If this option is turned on, the last error will always be saved in the $php_errormsg |
5. How to set the error level
1. Modify the value of error_reporting in the configuration file
2. In the code by error_reporting函数
setting the
* 1.error_reporting (0); Do not display errors except for E_parse
* 2.error_reporting (-1) | Error_reporting (E_all) Show All errors
3. Use Ini_set (' error_reporting ', 0) function runtime settings
6. Suppress Error output symbols
@
1. @
Settype ()
7. PHP Error via Trigger_error
- The ability to trigger errors is not limited to the PHP parser, but it can also
trigger_error()
trigger errors through functions.
- Trigger_error (' Error message ', custom error, such as: (E_user_notice)) trigger_error (' Custom error message ', E_user_notice);
- The function does not interrupt the program to continue execution.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
In-depth explanation: PHP socket Communication