Home >Backend Development >PHP Tutorial >PHP中Notice: Undefined index: sku in 问题解决方案

PHP中Notice: Undefined index: sku in 问题解决方案

WBOY
WBOYOriginal
2016-06-23 13:43:48897browse

这个不是bug,而且warning,当用$_GET[]或$_POST[]时不加isset之类判断的话,就会提示这个错误,Jones建议的解决方案完美解决这个问题:

<span style="font-family:Microsoft YaHei;font-size:14px;">function _get($str){    $val = !empty($_GET[$str]) ? $_GET[$str] : null;    return $val;}</span>

使用的时候,用法如下:

<span style="font-family:Microsoft YaHei;font-size:14px;">/** 计算总页数 */$sku = _get('sku');$warehouse = _get('warehouse');$supplier = _get('supplier');</span>

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
Previous article:关于json_encode()困惑Next article:php采集程序