Solution to the error when php variables are not declared: 1. Insert the "ini_set("error_reporting",E_ALL ^ E_NOTICE);" statement at the beginning of php; 2. Modify the configuration of php.ini.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
php variables are not declared. What should I do if an error is reported?
How to prevent undefined php variables from reporting errors?
In the process of php development, we often encounter problems: undefined variable...
The reason for the error is: the variable is not defined
However, according to the official documentation: php Variables do not need to be defined
So this creates a problem. During the development process, if we use undefined variables, bad results will occur. The reason for this problem is the error level of php.
So how to correct this problem?
First method: You can insert a statement at the beginning of php:
ini_set("error_reporting",E_ALL ^ E_NOTICE);
Second Method:
Modify the configuration of php.ini
In line 302 of php.ini error_reporting = E_ALL
Modify it to
error_reporting = E_ALL & ~E_NOTICE and then restart apache2.2
Solution: Modify php.ini
Change: error_reporting = E_ALL
Change to: error_reporting = E_ALL & ~E_NOTICE
If you don’t want any errors to be displayed, modify it directly:
Display_errors = Off
It is recommended to use the first method.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What should I do if an error is reported when PHP variables are not declared?. For more information, please follow other related articles on the PHP Chinese website!