刘洋的博客分享 http://blog.sciencenet.cn/u/outcrop 管中窥豹,盲人摸象

博文

Deprecated: Assigning the return value of new by reference is deprecated解决方法

已有 6810 次阅读 2010-10-1 03:01 |个人分类:计算机应用技术|系统分类:生活其它

解决办法:php5.3开始后,废除了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://wap.sciencenet.cn/blog-1750-368672.html

上一篇:Ubuntu启动修复
下一篇:历届Ig诺贝尔奖(搞笑诺贝尔奖)(1991-2010)
收藏 IP: .*| 热度|

0

发表评论 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-29 16:46

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部