php提示undefined index解决方法_PHP教程

WBOY
Libérer: 2016-07-13 17:13:58
original
1090 Les gens l'ont consulté

在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']:'';

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/629073.htmlTechArticle在php开发中经常会出现undefined index这种错误提示,下面我们看看方法总结吧。 平时用$_post[''],$_get['']获取表单中参数时会出现Notice: Undefine...
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!