0

我刚刚安装了 xampp,以运行一些旧程序(创建于 2 年或更多年前),但我遇到了 3 个我无法弄清楚的错误。

  1. 严格的标准:只有变量应该在 C:\xampp\htdocs\2010\web\core\route\route.php 的第 117 行通过引用传递
    public function loadClass($address,$ext='') {
        $this->extname = preg_replace('/_/','/',$address,3);
line:117>       $this->classname = end(explode('_',$address)).($e= $ext!='' ? '('.$ext.')' :  '');
        include_once(ROOT_ROUTE.'/'.$this->extname.'.php');
        $this->newclass = new $this->classname;
        return $this->newclass;
    }

第117行我看不懂,它没有使用通过引用传递,为什么会出现错误?

4

1 回答 1

4

因为 end() 需要一个通过引用传递的参数,所以不能将它与非变量一起使用,例如另一个函数调用或构造的直接结果。

引用手册中的参数定义:

这意味着您必须将一个实变量传递给它,而不是一个返回数组的函数,因为只有实际变量可以通过引用传递。

改变

$this->classname = end(explode('_',$address)).($e= $ext!='' ? '('.$ext.')' :  '');

$addressTemp = explode('_',$address);
$this->classname = end($addressTemp) . ($e= $ext!='' ? '('.$ext.')' :  '');
于 2013-01-24T08:55:47.430 回答