首页 > 代码库 > PHP中Notice: Undefined index: sku in 问题解决方案
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');
PHP中Notice: Undefined index: sku in 问题解决方案
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。