Home  >  Article  >  Backend Development  >  Solutions to php Undefined index and Undefined variable_PHP tutorial

Solutions to php Undefined index and Undefined variable_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:52:53860browse

$act=$_POST['act'];

Using the above code always prompts
Notice: Undefined index: act in F:windsflybookpost.php on line 18

In addition, sometimes There will also be

reference content
Notice: Undefined variable: Submit...

and other such prompts

Cause: caused by the variable being undefined

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
and change it to register_globals = On

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
 ...
 Originally, PHP does not need to define variables, but what should you do if this happens? What?
Just find the
of php.ini in C:WINDOWS. In php.ini, line 302 error_reporting = E_ALL
and 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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/318782.htmlTechArticle$act=$_POST['act']; Using the above code always prompts Notice:Undefinedindex:actinF:windsflybookpost .phponline18 In addition, sometimes the reference content Notice:Undefinedvariable:Submit....
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