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

PHP prompt undefined index solution_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 17:13:58
Original
1168 people have browsed it

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...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template