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

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

WBOY
Release: 2016-06-23 13:43:48
Original
884 people have browsed it

这个不是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>
Copy after login

使用的时候,用法如下:

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

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