Deprecated: Assigning the return value of new by reference is deprecated解决方法(PHP5.3)

最近在iis5.1下安装了php5.3.3,但很多程序出现Deprecated: Assigning the return value of new by reference is deprecated,找了半天才知道是php版本变动的原因。解决方法如下:

After hours of confusion and reading tons of posts I finally figured out that replacing PHP 4 style object creation, where new is assigned by reference:

$node_obj =& new someClass($somearg, $moreargs);

which in PHP 5.3.0 generates an E_STRICT message telling you that "Assigning the return value of new by reference is deprecated"

with the following, where & has been removed:

$node_obj = new someClass($somearg, $moreargs);

in some cases (at least in recursive loops while creating a tree of nodes containing child nodes) requires

unset($node_obj);

before the actual object assignment line to avoid all child nodes becoming identical.

Hope that delicate piece of information will save someone else a few hours.

版权声明:
作者:闲吧
链接:https://www.xianba.net/1878.html
来源:闲吧资源站
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>