$u1_nick = $this->session->userdata('userinfo')['screen_name'];如上的代码,在NetBeans里面报错,报错是:
"语法错误:
预期: instanceof, as, ->, =>, }, ',', OR, XOR, AND, =, +=, -=, *=, /=, .=, %=, &=, |+, ^=, <<=, >>=, ?, ';', ||, &&, |, ^, &, ==, !=, ===, !==, <=+, >=+, <, >, <<, >>, +, -, *, /, %, '.', ++, --, ], ), ':'
"
本人纯粹PHP新手,请大家指导一下,为什么在别人那儿是没问题的,是不是我有些PHP的特性没打开?非常感谢.

解决方案 »

  1.   

    完整的错误信息是什么? var_dump($this->session->userdata('userinfo'));  //贴出结果
      

  2.   

    谢谢楼上的高手相助,打印出那个变量的值是这样子的,但是在一个方法后面直接跟[]取值是正确的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
        [re] => 
        [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
    )
      

  3.   

    $u1_nick = $this->session->userdata('userinfo')['screen_name'];
    这种用法只在 php5.4 中是合法的
      

  4.   

    恩,非常感谢楼上的,我们是一个异地合作团队,估计是我们的PHP版本不一致,我这边确实是PHP 5.3.应该是这个问题.谢谢