PHP 版本升级会导致旧程序出错


php version upgrade cause an error for old program

我刚刚安装了 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行我看不懂,它没有使用通过引用传递,为什么会有错误?

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

引用手册中的参数定义:

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

改变

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

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