This kind of problem is that after you turn on the error prompt in php, it will tell you some errors in your programming. Now I will analyze the php Notice: Undefined index error prompt method for everyone. Friends in need can refer to it.
Cause Analysis
This kind of problem is usually caused by undefined variables
Example
The code is as follows
代码如下 |
复制代码 |
if($a)
{
echo $a;
}
else
{
}
|
|
Copy code
|
代码如下 |
复制代码 |
//解决
$a=1;
if($a)
{
echo $a;
}
else
{
}
//输出1
//在文章头部加
error_reporting(0);
if($a)
{
echo $a;
}
else
{
}
|
if($a)
{
echo $a;
}
else
{
} |
//Tips: Notice: Undefined variable: a in E:/www/test.php on line 5
The code is as follows
|
Copy code
//Solution
$a=1;
if($a)
{
echo $a;
}
else
{
}//Output 1
//Add to the head of the article
error_reporting(0);
if($a)
{
echo $a;
}
else
{
}
Summary of solutions
1. If the variable is not applied, directly declare the variable such as $a=1;.
2. Add error_reporting(0) at the head of the article; all errors will not be prompted
3. isset($_GET["page"]) or: @$page=$_GET["page"]
4. Use error_reporting = E_ALL & ~E_NOTICE in php.ini to turn off the display of notice and block such warnings,
http://www.bkjia.com/PHPjc/628857.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/628857.htmlTechArticleThis kind of problem is that after you turn on the error prompt in php, it will tell you some errors in your programming. , let me analyze the php Notice: Undefined index error prompt method for everyone, if necessary...
|
|