[ php ] php提示undefined index的几种解决方法!
来源:互联网 发布:linux常用命令mv 编辑:程序博客网 时间:2024/04/18 10:37
上面这些是 PHP 的提示而非报错.PHP 本身不需要事先声明变量即可直接使用,但是对未声明变量会有提示。
解决方法:
1 修改php.ini中的errror的错误显示方式。
将error_reporting= E_ALL 改为
error_reporting j= E_ALL & ~E_NOTICE
然后重启服务器即可。
2 对变量初始化
3 对变量进行判断
isset($_post['']),empty($_post['']) if --else
4 在notice代码之前加上@,表示有错误或者警告不要输出。
@$word = $_POST['word'];
5 最后一种方法
定义一个函数:
function _get($str){ $val = !empty($_GET[$str]) ? $_GET[$str] : null; return $val; }
每次调用即可, 如 _get('str') 代替 $_GET['str']
[PHP-Core-Error]
error_reporting = E_ALL & ~E_NOTICE
; 错误报告级别是位字段的叠加,推荐使用 E_ALL | E_STRICT
; 1 E_ERROR 致命的运行时错误
; 2 E_WARNING 运行时警告(非致命性错误)
; 4 E_PARSE 编译时解析错误
; 8 E_NOTICE 运行时提醒(经常是bug,也可能是有意的)
; 16 E_CORE_ERROR PHP启动时初始化过程中的致命错误
; 32 E_CORE_WARNING PHP启动时初始化过程中的警告(非致命性错)
; 64 E_COMPILE_ERROR 编译时致命性错
; 128 E_COMPILE_WARNING 编译时警告(非致命性错)
; 256 E_USER_ERROR 用户自定义的致命错误
; 512 E_USER_WARNING 用户自定义的警告(非致命性错误)
; 1024 E_USER_NOTICE 用户自定义的提醒(经常是bug,也可能是有意的)
; 2048 E_STRICT 编码标准化警告(建议如何修改以向前兼容)
; 4096 E_RECOVERABLE_ERROR 接近致命的运行时错误,若未被捕获则视同E_ERROR
; 6143 E_ALL 除E_STRICT外的所有错误(PHP6中为8191,即包含所有)
详细出处参考:http://www.jb51.net/article/30328.htm
- [ php ] php提示undefined index的几种解决方法!
- php提示undefined index的几种解决方法
- php提示undefined index的几种解决方法
- php提示undefined index的几种解决方法
- php提示undefined index的几种解决方法
- php提示undefined index的几种解决方法
- php提示undefined index的几种解决方法
- php提示undefined index的几种解决方法
- php提示undefined index的几种解决方法
- php:undefined index的几种解决方法
- php中提示Undefined index的解决方法
- php中提示Undefined index的解决方法
- php中提示Undefined index的解决方法
- php中提示Undefined index的解决方法
- php中提示Undefined index的解决方法
- php中提示Undefined index的解决方法
- php中提示Undefined index的解决方法
- php中提示Undefined index的解决方法
- 若无云,岂有风——词语语义相似度计算简介
- 第一章:JavaScript基础---(二)基础语法
- 用1,2....9组成三个三位数abc,def,ghi,每个数字恰好使用一次,要求abc:def:ghi=1:2:3,输出所有解
- 2.3.2 循环链表及基本操作
- 第四届全国ITAT教育工程就业技能大赛复赛试题Java组A卷答案
- [ php ] php提示undefined index的几种解决方法!
- Android开发规范
- 西南石油大学第三届信息安全大赛之QR码
- 串口基本常识
- 判断一个单向链表中是否有环
- 示波器与串口数据格式
- C++中的: 和 ::
- 宝马压路机与宝马轿车相撞
- 如何设置Android手机的sqlite3命令环境