During program debugging today, many source code provided on the Internet will encounter the Undefinedvariable error. generally, php does not need to define variables, but if the server reports an error for everything, errors will occur, so the server should block such errors.
This error is reported in the default PHP configuration. my PHP version is 5.2.13. this problem exists:
Notice: Undefined variable
This is to print out the warning on the page. Although this is conducive to exposing the problem, there will be many problems in implementation and use.
You need to set the display error level to solve the problem.
The common solution on the network is to modify the configuration of php. ini:
Solution:
1) error_reporting settings:
Locate error_reporting = E_ALL
Change to error_reporting = E_ALL &~ E_NOTICE
2) register_globals settings:
Find register_globals = Off
Change to register_globals = On
I found that using php code directly
Error_reporting (E_ALL &~ E_NOTICE );
This problem can be solved. remember it with tips.
The following is a supplement:
Notice: Undefined variable: email in D: \ PHP5 \ ENOTE \ ADDNOTE. PHP on line 9
Notice: Undefined variable: subject in D: \ PHP5 \ ENOTE \ ADDNOTE. PHP on line 9
Notice: Undefined variable: comment in D: \ PHP5 \ ENOTE \ ADDNOTE. PHP on line 9
........
In fact, the above is the undefined variable, and we will directly judge the code of the variable.
Php does not need to define variables, but what should I do in this case?
Find the php. ini file in C: \ WINDOWS.
Row 302 in php. ini: error_reporting = E_ALL
Modify
Error_reporting = E_ALL &~ E_NOTICE: restart apache2.2.
Solution: modify php. ini
Yes: error_reporting = E_ALL
Changed to: error_reporting = E_ALL &~ E_NOTICE
If you do not want to display any errors, modify them directly:
Display_errors = Off
If you do not have permission to modify php. ini, you can add it to the php header.
Ini_set ("error_reporting", "E_ALL &~ E_NOTICE ");
You can.