报错:Use of undefined constant allowhtml 与Undefined index

大川韬滔 2015-09-30 10:26:42
运行程序报如下错误,这是哪里出问题了?
Notice: Use of undefined constant allowhtml - assumed 'allowhtml' in /home/wwwroot/kaimen360_com/public_html/uc_client/model/base.php on line 69

Notice: Undefined index: allowhtml in /home/wwwroot/kaimen360_com/public_html/uc_client/model/base.php on line 69
...全文
161 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
傲雪星枫 2015-10-08
  • 打赏
  • 举报
回复
引用 4 楼 u010275498 的回复:
[quote=引用 3 楼 fdipzone 的回复:] 数组中allowhtml的键值不存在而被使用了。 例如:

<?php
$arr = array('a'=>123);
echo $arr['allowhtml'];  // 这样就会有提示未定义了。
?>
怎么解决呀? 我迁移了服务器就报这样的错误,没有迁移服务器前好好的,这是为什么?[/quote] 那是因为你的旧服务器设置了不输出notice,warning的错误,所以不显示。 你可以在程序顶加上 error_reporting(E_ALL^E_NOTICE^E_WARNING);

<?php
error_reporting(E_ALL^E_NOTICE^E_WARNING); // 加了这句就可以屏蔽警告与提示的错误。
$arr = array('a'=>123);
echo $arr['allowhtml']; // 这里不会出现notice
?>
xuzuning 2015-10-05
  • 打赏
  • 举报
回复
$a = array(); echo $a[allowhtml]; 关联键名没有用引号括起(不是字符串),php 会先检查是否为常量,由于没有定义,所以有 Notice: Use of undefined constant allowhtml - assumed 'allowhtml' in ... 然后按字符串检查数组中是否有同名项,因为没有,所以有 Notice: Undefined index: allowhtml in ... 这是因为你没有书写健壮的代码造成的 php.ini 中默认 error_reporting = E_ALL 你可改为 error_reporting = E_ALL ^ E_NOTICE 或在程序开始处执行 error_reporting(E_ALL ^ E_NOTICE); 来补偿你的过失
大川韬滔 2015-10-04
  • 打赏
  • 举报
回复
引用 3 楼 fdipzone 的回复:
数组中allowhtml的键值不存在而被使用了。 例如:

<?php
$arr = array('a'=>123);
echo $arr['allowhtml'];  // 这样就会有提示未定义了。
?>
怎么解决呀? 我迁移了服务器就报这样的错误,没有迁移服务器前好好的,这是为什么?
傲雪星枫 2015-10-01
  • 打赏
  • 举报
回复
数组中allowhtml的键值不存在而被使用了。 例如:

<?php
$arr = array('a'=>123);
echo $arr['allowhtml'];  // 这样就会有提示未定义了。
?>
果酱很好吃 2015-09-30
  • 打赏
  • 举报
回复
提示你,在数组中没有那个键名(不存在)为 allowhtml 的数据
xuzuning 2015-09-30
  • 打赏
  • 举报
回复
使用了未经定义(不存在)的关联键 错误信息已给出的出错位置 /home/wwwroot/kaimen360_com/public_html/uc_client/model/base.php on line 69 麻烦你自己看一下

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧