php提示Notice: Undefined index 错误解决办法
原因分析
出现这种问题一般是变量未定义造成的
例
<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy1440')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy1440>if($a)
{
echo $a;
}
else
{
}
//提示:Notice: Undefined variable: a in E:/www/test.php on line 5
<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy7761')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy7761>
//解决
$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的显示,屏蔽掉此类警告好,
您可能感兴趣的文章:
PHP运行出现Notice : Use of undefined constant 的解决方法
PHP Notice: undefined index原因与解决办法
php错误Undefined variable: 如何解决
php出现Notice : Use of undefined constant 的解决方法
php提示Notice: Undefined variable的解决办法
php中出现Undefined index和Undefined variable的解决方法
php报错Notice: Undefined variable的解决办法
php提示Notice: Undefined index 错误解决办法
PHP “Notice: Undefined variable” 和 “Notice: Undefined index”报错
Notice: Undefined index: page in E:\PHP\test.php on line 14的处理方法