php中的call-time pass-by-reference问题

时间:2012-11-20 06:21:35

标签: php

  

可能重复:
  Call-time pass-by-reference has been deprecated;

function getLib($pfComponentType,$pfComponentCode,$componentCode)
    {
        if($temp=require_once($this->getConfig($pfComponentType,$pfComponentCode,'librariesPath').$componentCode.'.php'))
        {
            $obj_lib = __NAMESPACE__.'\\'.$componentCode;
            return new $obj_lib(&$this);
        }
        else return NULL;
    }

我收到一条错误消息,称在上述函数的第6行中删除了Call-time pass-by-reference,即返回new $ obj_lib(& $ this);

1 个答案:

答案 0 :(得分:1)

$obj_lib没有按引用传递参数,因此您无法将其传递给引用。从&移除&$this,或在&定义的参数中添加$obj_lib