Pear::Authで Assigning the return value of new by reference is deprecatedというエラー


Pear::Authで Assigning the return value of new by reference is deprecatedというエラーが出る場合の対応方法。

PHPのバージョンを上げたら「Assigning the return value of new by reference is deprecated」というエラーメッセージが表示されるようになってしまいました。

対処方法としては、php/pear/Auth.php の469行目の

 $obj =& new $storage_class($options);

 $obj = new $storage_class($options);

のように & をとれば解決できます。

エラーメッセージの意味は「new の戻り値を参照渡しで変数に代入することはできません」。

PHPではバージョン5から new 演算子は自動的に参照を返すように仕様が変更になりました。
また、PHP5.2からはnew の結果を参照で編集に代入するとエラーになるようになりました。

タグ: ,
カテゴリー: PHP
カテゴリー