Home >Backend Development >PHP Tutorial >PHP Notice: undefined index causes and solutions_PHP tutorial

PHP Notice: undefined index causes and solutions_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 10:56:411213browse

When developing PHP, you may encounter error messages such as PHP Notice: undefined index. Let me introduce to you the solution to the undefined index error message.

For example $_GET['aa']; PHP Notice: undefined index ‘aa‘ will appear.

Let me summarize the solutions to PHP Notice: undefined index.

1. php.ini configuration file, error_reporting = E_ALL & ~E_NOTICE

2. Add an isset function isset($_GET["page"]) if-else judgment

Another way is to customize a function, so that you can directly use the function operation

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

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

Copy code


function _get($str){

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

Return $val;

_get('str') instead of $_GET['str'] can http://www.bkjia.com/PHPjc/632144.html
www.bkjia.comtrue
http: //www.bkjia.com/PHPjc/632144.htmlTechArticleWhen developing PHP, you may encounter errors such as PHP Notice: undefined index. Let me tell you about it below. Introducing the solution to the undefined index error message. For example, $_GET['aa']; will...
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