Home > php教程 > php手册 > php提示undefined index解决方法

php提示undefined index解决方法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 10:14:59
Original
1006 people have browsed it

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

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

服务器配置修改
修改php.ini配置文件,

 代码如下 复制代码
error_reporting = E_ALL & ~E_NOTICE

程序判断

 代码如下 复制代码

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

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

 代码如下 复制代码

error_reporting(E_ALL ^ E_NOTICE);

用isset方法

 代码如下 复制代码

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

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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template