Home  >  Article  >  Backend Development  >  PHP prompt undefined index solution_PHP tutorial

PHP prompt undefined index solution_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:13:581123browse

Undefined index error messages often appear in PHP development. Let’s take a look at a summary of the methods below.

When you usually use $_post[''], $_get[''] to obtain the parameters in the form, Notice: Undefined index: --------;

Server configuration modification
Modify the php.ini configuration file,

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

Program Judgment

The code is as follows
 代码如下 复制代码

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

Copy code

 代码如下 复制代码

error_reporting(E_ALL ^ E_NOTICE);

function _get($str){

$val = !empty($_GET[$str]) ? $_GET[$str] : null;

return $val;
 代码如下 复制代码

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

}

Another way is to close the error code in php

The code is as follows Copy code
error_reporting(E_ALL ^ ​​E_NOTICE); Use isset method
The code is as follows Copy code
$var = isset($_GET['a'])?$_GET['a']:'';
http://www.bkjia.com/PHPjc/629073.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/629073.htmlTechArticleError messages like undefined index often appear in PHP development. Let’s take a look at the method summary. Usually when using $_post[''], $_get[''] to obtain parameters in the form, Notice: Undefine...
Statement:
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