Home >Backend Development >PHP Tutorial >Solution to php error Notice: Undefined variable

Solution to php error Notice: Undefined variable

WBOY
WBOYOriginal
2016-07-25 09:05:151382browse
When debugging the source code downloaded from the Internet, most errors of Undefined variable appear. Under normal circumstances, PHP does not need to define variables, but if the server reports everything as an error, an error will occur, so this kind of error should be blocked on the server.

The source code downloaded from the Internet often causes Undefined variable errors during debugging. Under normal circumstances, PHP does not need to define variables, but if the server reports everything as an error, an error will occur, so this kind of error should be blocked on the server. Notice: Undefined variable: email in D:PHP5ENOTEADDNOTE.PHP on line 9 Notice: Undefined variable: subject in D:PHP5ENOTEADDNOTE.PHP on line 9 Notice: Undefined variable: comment in D:PHP5ENOTEADDNOTE.PHP on line 9 ........

In fact, the above is an undefined variable, we will directly determine the code of the variable. Originally, PHP does not need to define variables, but what should we do if this happens? Just find php.ini in C:WINDOWS

In php.ini line 302 error_reporting = E_ALL changed to error_reporting = E_ALL & ~E_NOTICE Just restart apache2.2

Solution: Modify php.ini Change: error_reporting = E_ALL Modify to: error_reporting = E_ALL & ~E_NOTICE

If you don’t want any errors to be displayed, modify them directly: display_errors = Off If you do not have permission to modify php.ini, you can add: ini_set("error_reporting","E_ALL & ~E_NOTICE");



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn