基础问题,菜鸟求救,非常感谢.

anyue417 2012-07-23 07:01:26
$u1_nick = $this->session->userdata('userinfo')['screen_name'];

如上的代码,在NetBeans里面报错,报错是:
"语法错误:
预期: instanceof, as, ->, =>, }, ',', OR, XOR, AND, =, +=, -=, *=, /=, .=, %=, &=, |+, ^=, <<=, >>=, ?, ';', ||, &&, |, ^, &, ==, !=, ===, !==, <=+, >=+, <, >, <<, >>, +, -, *, /, %, '.', ++, --, ], ), ':'
"
本人纯粹PHP新手,请大家指导一下,为什么在别人那儿是没问题的,是不是我有些PHP的特性没打开?非常感谢.
...全文
83 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
anyue417 2012-07-23
  • 打赏
  • 举报
回复
恩,非常感谢楼上的,我们是一个异地合作团队,估计是我们的PHP版本不一致,我这边确实是PHP 5.3.应该是这个问题.谢谢
xuzuning 2012-07-23
  • 打赏
  • 举报
回复
$u1_nick = $this->session->userdata('userinfo')['screen_name'];
这种用法只在 php5.4 中是合法的
anyue417 2012-07-23
  • 打赏
  • 举报
回复
谢谢楼上的高手相助,打印出那个变量的值是这样子的,但是在一个方法后面直接跟[]取值是正确的PHP语法么?

Array
(
[id] => 168780872
[idstr] => 168780872
[screen_name] => 醉仙
[name] => 醉仙
[province] => 5
[city] => 1
[location] => 四川 成都
[description] =>
[url] =>
[profile_image_url] => http://tp1.sinaimg.cn/168787872/50/563407034/1
[profile_url] => u/168770872
[domain] =>
[weihao] =>
[gender] => m
[followers_count] => 4
[friends_count] => 15
[statuses_count] => 26
[favourites_count] => 0
[created_at] => Sat Jan 30 23:09:57 +0800 2010
[following] =>
[allow_all_act_msg] =>
[geo_enabled] =>
[verified] =>
[verified_type] => -1
[remark] =>
[status] => Array
(
[created_at] => Mon Jul 23 19:20:57 +0800 2012
[id] => 3.4710340007647E+15
[mid] => 3471034000764735
[idstr] => 3471034000764735
[text] => 我以前总感觉的多,结果......................................................不是........
[source] => 新浪微博
[favorited] =>
[truncated] =>
[in_reply_to_status_id] =>
[in_reply_to_user_id] =>
[in_reply_to_screen_name] =>
[geo] =>
[reposts_count] => 0
[comments_count] => 0
[mlevel] => 0
[visible] => Array
(
[type] => 0
[list_id] => 0
)

)

[allow_all_comment] =>
[avatar_large] => http://tp1.sinamg.cn/168780872/180/565407034/1
[verified_reason] =>
[follow_me] =>
[online_status] => 0
[bi_followers_count] => 6
[lang] => zh-cn
)
一起混吧 2012-07-23
  • 打赏
  • 举报
回复
完整的错误信息是什么? var_dump($this->session->userdata('userinfo')); //贴出结果

21,886

社区成员

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

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