Home > Backend Development > PHP Tutorial > PHP prompt Notice: Undefined variable solution

PHP prompt Notice: Undefined variable solution

WBOY
Release: 2016-07-28 08:29:57
Original
1055 people have browsed it
Notice: Undefined variable
 This is to print the warning on the page. Although this is helpful for exposing problems, 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 Internet is to modify the configuration of php.ini:
Solution:

 1) error_reporting setting:
Find error_reporting = E_ALL
 Change to error_reporting = E_ALL & ~E_NOTICE
 2) register_globals setting:
 Find register_globals = Off
 Changed to register_globals = On
  I found that using
 error_reporting(E_ALL & ~E_NOTICE);
  directly in the php code can solve this problem, please remember the tips, haha.
The following is a supplement:
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 you do if this happens?
 Just find php.ini in C:WINDOWS
 In line 302 of php.ini error_reporting = E_ALL
 Change it to
 error_reporting = E_ALL & ~E_NOTICE and then restart apache2.2.
Solution: Modify php.ini
Change: error_reporting = E_ALL
to: error_reporting = E_ALL & ~E_NOTICE
If you don’t want any errors to be displayed, directly modify:
display_errors = Off
 If you do not have permission to modify php.ini, you can add
 ini_set("error_reporting", "E_ALL & ~E_NOTICE");
  to the php header

The above introduces the solution to the PHP prompt Notice: Undefined variable, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template