Home > php教程 > php手册 > body text

php提示Notice: Undefined index 错误解决办法

WBOY
Release: 2016-06-13 10:16:15
Original
2337 people have browsed it

这种问题是你php中把错误提示开启了之后,会把你编程的一些错误给告诉你,下面我来给大家分析php Notice: Undefined index 错误提示方法,有需要的朋友可参考。

原因分析

出现这种问题一般是变量未定义造成的

 代码如下 复制代码

if($a)
{
 echo $a;
}
else
{

}

//提示:Notice: Undefined variable: a in E:/www/test.php on line 5

 代码如下 复制代码


//解决

$a=1;
if($a)
{
 echo $a;
}
else
{

}

//输出1
//在文章头部加

error_reporting(0);

if($a)
{
 echo $a;
}
else
{

}

解决方法总结

1、如果是变量未申请直接申名变量如 $a=1; 这样。
2、在文章头部加error_reporting(0);  所有错误都不提示
3、isset($_GET["page"])  或 :@$page=$_GET["page"]
4、用php.ini中error_reporting   =   E_ALL   &   ~E_NOTICE 可以关闭notice的显示,屏蔽掉此类警告好,

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!