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

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

WBOY
WBOYOriginal
2016-06-13 12:11:26813browse

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

这个不是bug,而是warning,当用$_GET[]或$_POST[]时不加isset之类判断的话,就会提示这个错误。

Jones建议的解决方案,完美的解决了这个问题:

/* * 取代$_GET[]获取值 */function _get($str) {	$val = !empty($_GET[$str]) ? $_GET[$str] : null;	return $val;}/* * 取代$_POST[]获取值 */function _post($str) {	$val = !empty($_POST[$str]) ? $_POST[$str] : null;	return $val;}

使用的时候,用法如下:

/** 设置当前页数 */$page = _get('page');$inventory->setCurrentPage($page);/** 计算总页数 */$sku = _post('sku');$warehouse = _post('warehouse');$supplier = _post('supplier');

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