php总是显示notice会有什么影响吗?会不会影响功能?
答案:2 悬赏:20
解决时间 2021-12-28 23:47
- 提问者网友:风华是一指流沙
- 2021-12-28 14:39
php总是显示notice会有什么影响吗?会不会影响功能?
最佳答案
- 二级知识专家网友:我颠覆世界
- 2021-12-28 15:35
虽然PHP不需要定义变量, 但尽量在 { } 块之外初始化变量.
比如
if (!empty($arr)) {
$msg = 'not empty';
} else {
$msg = 'is empty';
}
echo $msg;
这里会有个 notice 说 $msg 未定义或 not isset.
你只需在 {} 块之前初始化一下就可以了.
$arr = array(); # 初始化
if (!empty($arr)) {
$msg = 'not empty';
} else {
$msg = 'is empty';
}
echo $msg;
更完美点:
你在程序开头写上 error_reporting(E_ALL);
然后运行能不出其它任何PHP提示, 这样更好了. 无错总比有错运行快.
比如
if (!empty($arr)) {
$msg = 'not empty';
} else {
$msg = 'is empty';
}
echo $msg;
这里会有个 notice 说 $msg 未定义或 not isset.
你只需在 {} 块之前初始化一下就可以了.
$arr = array(); # 初始化
if (!empty($arr)) {
$msg = 'not empty';
} else {
$msg = 'is empty';
}
echo $msg;
更完美点:
你在程序开头写上 error_reporting(E_ALL);
然后运行能不出其它任何PHP提示, 这样更好了. 无错总比有错运行快.
全部回答
- 1楼网友:為→妳鎖鈊
- 2021-12-28 16:01
$_session["string"],中string中关联数组下标不能为纯数字,即不能是整数,因为纯整数的字符串在php数组下标中就作为索引下标处理。浮点就可以,哈哈。。也就是说$_session["
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯