PHPerror_reporting (E_ALL ^ E_NOTICE) detailed description of the error report. This article describes in detail some methods to enable and disable the error prompt in PHP, error_reporting, and PHPerror_reporting (E_ALL ^ E_NOTICE, for more information about how to enable and disable the error prompt in PHP, error_reporting, and PHP error_reporting (E_ALL ^ E_NOTICE), see this article, for more information, see.
Example:
In Windows: The program that was originally running normally in php4.3.0 has multiple errors in 4.3.1. the general prompt is: Notice: Undefined varialbe: variable name.
For example, the following code is available:
The code is as follows: |
|
If (! $ Tmp_ I ){ $ Tmp_ I = 10; }
|
Run normally in 4.3.0. when running 4.3.1, the system prompts Notice: Undefined varialbe: tmp_ I.
The problem is as follows:
1. where is the problem?
2. how should I modify this code?
3. do not change the code segment. how to modify the settings in php. ini so that the original program in 4.3.0 runs normally in the 4.3.1 environment without the error message.
Solution:
Open the PHP. ini file in the php installation directory.
Find display_errors = On and change it to display_errors = off.
Note: If you have copied the PHP. ini file to the windows directory, you must change display_errors = On in c: windows/php. ini to display_errors = off.
2. how to output a script error message as a log file:
Open the PHP. ini file in the php installation directory.
Find log_errors = off and change it to log_errors = on.
Find error_log = filename and change it to error_log = "D: PHPerrlogphp_error.log" (here, the directory and file name D: PHPerrlogphp_error.log are whatever you want)
Note: If you have copied the PHP. ini file to the windows directory, you must also copy the c: windows/php. ini file.
In addition, php_error.log must have at least the USER's modification and write permissions. Otherwise, the error log cannot be output.
Related error_reporting () functions:
Error_reporting () sets the PHP error level and returns the current level.
; Error reports are reported by bit. Or add the numbers to get the expected error report level.
; E_ALL-all errors and warnings
; E_ERROR-fatal runtime error
; E_WARNING-runtime warning (non-fatal error)
; E_PARSE-parsing error during compilation
; E_NOTICE-runtime reminder (these are often caused by bugs in your code, or intentional behavior. (For example, an uninitialized variable is used based on the fact that the uninitialized variable is automatically initialized to an empty string)
; E_CORE_ERROR-fatal error during PHP startup initialization
; E_CORE_WARNING-warning occurred during PHP startup initialization (non-fatal error)
; E_COMPILE_ERROR-fatal error during compilation
; E_COMPILE_WARNING-warning during compilation (non-fatal error)
; E_USER_ERROR-error message generated by the user
; E_USER_WARNING-user-generated warning message
; E_USER_NOTICE-user-generated reminder message
Usage:
Error_reporting (0); // disable error reporting
Error_reporting (E_ALL ^ E_NOTICE); // display all error messages except E_NOTICE
Error_reporting (E_ALL ^ E_WARNING ^ E_NOTICE); // display all error messages except E_WARNING E_NOTICE
Error_reporting (E_ERROR | E_WARNING | E_PARSE); // displays a runtime error, which is the same as error_reporting (E_ALL ^ E_NOTICE. Error_reporting (E_ALL); // display all errors
Can I disable the PHP error prompt? I don't want others to see my program's error.
Answer:
Because PHP. the settings in ini are global. we cannot directly modify the global configuration information for a single user, but you can use the php function error_reporting to adjust the error information output of the script you are running, for example:
The code is as follows: |
|
Error_reporting (E_ALL ^ E_NOTICE ^ E_WARNING ); |
Disable all notice and warning errors.
Put this statement in the function inclusion file of your script, which is usually controlled by config. php or conn. php.
The code is as follows: |
|
// Disable error reporting Error_reporting (0 ); // Report running errors Error_reporting (E_ERROR | E_WARNING | E_PARSE ); // Report all errors Error_reporting (E_ALL ); ?> |
Assumerror_reporting (E_ALL ^ E_NOTICE) some methods to enable and disable the error prompt are summarized. if you need it, refer to 1...