Home > php教程 > php手册 > Notice:undefined index ..错误提示解决方法

Notice:undefined index ..错误提示解决方法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-25 16:52:45
Original
1255 people have browsed it

一,这个因为是变量未定义我们只要找到相关的位置加上如下代码:

function _get($str){  
$val = !emptyempty($_GET[$str]) ? $_GET[$str] : null;  
    return $val;  
}
Copy after login

或者我们可以这样:

isset($_GET['你的变量'])?$_GET['你的变量']:'';

上面我们只举了get的用法还有post也一样,只要把上面的get改成post.还有一种程序的全局定义方法:

if (!$cfg['debug']) { 
    error_reporting(0); 
    ob_start('ob_gzhandler'); 
} else { 
    error_reporting(E_ALL ^ E_NOTICE); 
}
Copy after login

这样我们只要对变量debug进行设置0或1对错误提示进行开关了.

其它网页提供的方法:

方法1:服务器配置修改,修改php.ini配置文件,error_reporting = E_ALL & ~E_NOTICE

方法2:在出现notice代码之前加上@,@表示这行有错误或是警告不要输出,@$username=$_post['username'];

注:如果你是利用了全局定义或在修改php.ini配置文件这样所有错误提示都不会出,这样对于开发测试来讲是相当的麻烦的,建义利用程序的方法,关闭错误提示最在在服务器上设置。


Related labels:
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