首页 > php开发 > php提示undefined index解决方法

php提示undefined index解决方法

在php开发中经常会出现undefined index这种错误提示,下面我们看看方法总结吧.

平时用$_post[''],$_get['']获取表单中参数时会出现Notice: Undefined index: --------;

服务器配置修改

修改php.ini配置文件,

实例代码如下:

error_reporting = E_ALL & ~E_NOTICE

程序判断

实例代码如下:

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

还有一种方法就是在php把错误关闭了代码

实例代码如下:

error_reporting(E_ALL ^ E_NOTICE);

用isset方法

实例代码如下:

$var = isset($_GET['a'])?$_GET['a']:'';

               
               

本文地址:http://www.phprm.com/develop/fs2439.html

转载随意,但请附上文章地址:-)

标签:index phpundefined 解决方法

相关文章

发表留言