【问题标题】:Deprecated: Assigning the return value of new by reference is deprecated in D:\xampp\php\PEAR\Config.php on line 80不推荐使用:在第 80 行的 D:\xampp\php\PEAR\Config.php 中不推荐使用通过引用分配 new 的返回值
【发布时间】:2023-03-26 18:55:01
【问题描述】:
    <?php
/**
* This class is sort of factory class that is responsible for loading
* classes, it check if this class is not defined then it includes the file
* So developer don't need to worry about including that file
* @author Haafiz
*/
class load{

    public static $app_path= APP_PATH;
    public static $model_path=MODEL_PATH;


    /*
    * @param string $model_name <>Name of class(model) that is required to instantiate/load</p>
    * @param bool $continue_on_error  this decide whether to have fatal error or continue on error loading
    * $return object 
    */
    public static function model($model_name,$conitnue_on_error=0){
        if(!class_exists($model_name)){
            $model_filename= strtolower($model_name).".php";
            try{
                include self::$model_path.$model_filename;
            }
            catch(Exception $e){
                if(!$continue_on_error){
                die($e);
                }
            }
            $model=new $model_name();
            return $model;
        }       
    }
}

?>

在上面的代码中必须面对以下错误。有些人在其他一些线程中说问题在于使用 &amp; ,我没有使用它。那么在我的情况下实际上是什么问题?一切似乎都正确地做每一件事。看到了一些其他线程,但没有找到任何解决方案。所以请如果其他人理解它。 谢谢

【问题讨论】:

  • 问题出在这里:D:\xampp\php\PEAR\Config.php on line 80。而且很可能在那里使用了&amp;
  • 这个文件看起来不像你的Config.php文件...所有的配置在哪里?
  • 我似乎记得在 5.1 中通过引用进行分配更快,因此它在某些圈子中变得很普遍......很高兴看到情况得到解决并且现在不推荐使用这种做法 =)跨度>

标签: php xampp php-5.3 deprecated


【解决方案1】:

php/PEAR/Config.php 中的第 80 行确实使用了引用。

   function Config()
    {
        $this->container =& new Config_Container('section', 'root');
    } // end constructor

请参考this question关于这个问题和更新你的PEAR包。

【讨论】:

  • 但这不是我的文件,它来自 php 附带的东西,我尝试更新 pear 但再次出现错误,pear 尝试更新错误目录中的设置
猜你喜欢
  • 1970-01-01
  • 2012-12-21
  • 1970-01-01
  • 2013-05-24
  • 2010-11-08
相关资源
最近更新 更多