PHP prompt undefined index solution_PHP tutorial

WBOY
Release: 2016-07-13 17:13:58
Original
1090 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!