【问题标题】:Fatal error: Call-time pass-by-reference has been removed in function.php致命错误:在 function.php 中删除了调用时传递引用
【发布时间】:2014-06-21 15:22:53
【问题描述】:

我正在为网站使用 WordPress,但是当我运行我的网站时,我收到标题中指定的错误消息。它说错误在文件functions.php中,在第32行。下面你可以找到那部分代码:

class Walker_Nav_Menu_Mobile extends Walker_Nav_Menu{

    // don't output children opening tag (`<ul>`)
    public function start_lvl(&$output, $depth){}

    // don't output children closing tag    
    public function end_lvl(&$output, $depth){}

    public function start_el(&$output, $item, $depth, $args){

      // add spacing to the title based on the current depth
      $item->title = str_repeat("&nbsp;", $depth * 4) . $item->title;

      // call the prototype and replace the <li> tag
      // from the generated markup...
      parent::start_el(&$output, $item, $depth, $args); // LINE 32 IS THIS ONE!
      $output = strip_tags($output, '<li><option>');
      $output = str_replace("</option>
</option>","</option>", $output);
      $output = str_replace('<li', '<option value="'.$item->url.'"', $output);
    }
    // replace closing </li> with the closing option tag
    public function end_el(&$output, $item, $depth){
      $output .= "</option>\n";
    }
}

【问题讨论】:

    标签: php wordpress


    【解决方案1】:

    从 PHP 5.3.0 开始,当您在函数调用上使用引用符号时,您将收到一条警告,指出“调用时传递引用”已被弃用。仅在函数定义中使用参考符号 (Passing by Reference)。

    // wrong
    parent::start_el( &$output, $item, $depth, $args );
    
    // right
    parent::start_el( $output, $item, $depth, $args );
    

    【讨论】:

      猜你喜欢
      • 2013-11-17
      • 2017-01-29
      • 1970-01-01
      • 2015-06-16
      • 1970-01-01
      • 2014-01-12
      • 2012-11-13
      • 1970-01-01
      相关资源
      最近更新 更多