【问题标题】:Fatal error: Cannot access empty property in致命错误:无法访问空属性
【发布时间】:2015-06-25 18:21:18
【问题描述】:

这里是新的,所以如果我的帖子不正确,请原谅我。我遇到了这个问题:

致命错误:无法访问空属性 /home/content/c/a/l/calchrome/html/gallery/php/includes/php/libmanager.php 在第 1363 行

我在这里找不到语法错误;通常这样的事情很明显,但我无法弄清楚这一点。这不是通常的$this->$var 类型错误。

   foreach($cfg['social_plugin'] as $plugin=>$value)
    {
        $social_order[$this->$value['order']] = $plugin;
    }

    ksort($social_order);

    for($a=1;$a<sizeof($social_order)+1;$a++)

  **this is the section with the problem** 
    {
        $obj = $cfg['social_plugin'][$social_order[$a]];
        $list.='<li id="'.$obj['order'].'_'.($a+1).'"><label for="'.$obj['link'].'"><img src="includes/images/'.$obj['image'].'" /> '.$obj['display'].'</label><input name="'.$social_order[$a].'_L" type="text" id="'.$social_order[$a].'_L" value="'.$this->$obj['link'].'" class="sg_form_long"/></li>';     
    }**

    $html.='<div class="sg_setting_box" id="sortable1">
    <h3>- Soical Information -
    <br/><span>Dragging each plugin can re-arrange the order shown in front end</span>
    </h3>


    <ul class="sg_social">'.$list.'</ul>

    </div>';

【问题讨论】:

  • 欢迎来到 Stack Overflow!为了帮助获得更好的答案,您的程序使用什么语言?看起来像perl;如果是这样,请将其添加到标签中,以帮助 Perl 专家找到它。
  • 对不起,这是模块的一部分,我不太确定 php 之外
  • 希望我的编辑有所帮助。次要 nitpick:“无法访问空属性”是运行时错误(意外状态)而不是语法错误(不遵循语言规则)。有点像不真实的句子和拼写错误的区别。

标签: php fatal-error


【解决方案1】:

变化:

$this->$obj['link']

$obj['link']

$this-&gt; 用于当前类属性

【讨论】:

    【解决方案2】:

    你应该改变(如果 obj 在你的类中定义为属性) 来自

    $this->$obj['link']
    

    $this->obj['link']
    

    OR(如果 obj 仅定义为局部变量)

    到 $obj['链接']

    正如上面的答案所建议的那样

    【讨论】:

      猜你喜欢
      • 2013-02-01
      • 1970-01-01
      • 2015-06-13
      • 1970-01-01
      • 2013-08-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多