Call-time pass-by-reference was deprecated in PHP 5.3.0 (2009) and it was removed as of PHP 5.4.0 (2012). But still I meet this problem on older PHP projects when migrating them to new server. How to find all occurences of "call-time pass-by-reference" in PHP project and remove/repair them?
关注
码龄 粉丝数 原力等级 --
- 被采纳
- 被点赞
- 采纳率

已采纳
如何在PHP项目中找到所有出现的“call-time pass-by-reference”并删除/修复它们?
收起
- 写回答
- 好问题 0 提建议
- 关注问题
微信扫一扫
点击复制链接分享
- 邀请回答
- 编辑 收藏 删除 结题
- 收藏 举报
1条回答 默认 最新
- 关注
码龄 粉丝数 原力等级 --
- 被采纳
- 被点赞
- 采纳率
dslfjrmz70457 2017-04-05 11:35关注There is no automatic way to do this (at least I have not found any). It must be done manually. Call-time pass-by-references can be found in project files quite precisely by following regex (use your IDE to launch regex serach):
(?<!function)[:> ][a-zA-Z0-9_]+(?<!foreach|array)\s?\([^()]*&\$
Found occurences you must repair one by one manually. You have to:
- Remove the ampersand sign in function/method calls. E.g. something like
$myResult = myFunction(&$myVar)
you will rewrite to$myResult = myFunction($myVar)
. - Check if
myFunction()
is defined with first argument passed by reference likefunction myFunction(&$myArg1)
. If not (it means the ampersand is missing in definition) then you must repair it and add the ampersand - If the ampersand was missing in the definition of
myFunction()
then you must check if all calls ofmyFunction()
in project are done with "call-time pass-by-reference". If yes then you are done. If not (it means there are calls ofmyFunction()
without "call-time pass-by-reference") then you must consider if it changes something if you use pass-by-reference and if yes then you should write a pas-by-value ofmyFunction()
and use it for these occurences
本回答被题主选为最佳回答 , 对您是否有帮助呢? 本回答被专家选为最佳回答 , 对您是否有帮助呢? 本回答被题主和专家选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏举报微信扫一扫
点击复制链接分享
编辑预览轻敲空格完成输入- 显示为
- 卡片
- 标题
- 链接
评论按下Enter换行,Ctrl+Enter发表内容
编辑
预览

轻敲空格完成输入
- 显示为
- 卡片
- 标题
- 链接
报告相同问题?
提交
- 济时彦的博客 升级的具体细节如下:1、PHP 5.3.7在安全方面的改进和修复:●Updated crypt_blowfish to 1.2. (CVE-2011-2483)●Fixed crash in error_log(). Reported by Mateusz Kocielski●Fixed buffer overflow on overlog ...
- 2019-03-18 13:15鸟飞惊了看花人的博客 Session与cookie的区别?...里面的session.save_path找到存放位置 cookie不是很安全 ,cookie可以进行cookie欺骗,别人可以获取cookie中的session id考虑到安全应当使用session。 session会在一定时间内保存在服务器...
- 2021-04-09 04:43全宇宙的三姐的博客 这些都记录在PHPPassing by Reference手册页上.具体(加重我的):Note: There is no reference sign on a function call – only on functiondefinitions. Function definitions alone are enough to correctly ...
- 2018-12-29 02:12weixin_34227447的博客 最近在用solr做一个高速的缓存系统,使用的php版本是7.2,我用的是本地mac系统,在使用homebrew安装php72-solr扩展的时候找不到这个包,没办法只能自己编译安装。但是安装过程比较坎坷,solr的扩展在php7.2编译安装...
- 2021-03-22 13:47二师姐聊保险的博客 serialize可以将对象转换为字符串并且在转换中可以保存当前变量的值。unserialize则可以将serialize生成的字符串变换回对象。0x01序列化类型boolean:b:1;//Trueb:0;//Falseintegeri:1;doubled:1.23456NULLN;strings...
- 2021-02-10 03:30weixin_39968640的博客 这篇文章介绍的内容是关于PHP 经典面试题集 PHP 经典面试题集,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下结合我自己面试情况,面对的一些php面试题列举出来,基本上结合自己的看法回答的,不妥...
- 2023-10-05 10:26mpp__mvp的博客 若另一台主机上的POD的主机故障了,那运行在这个主机上的POD会消亡,控制器会删除那个故障POD在其它主机节点重新创建这个副本,保证集群有3个POD。 k8s框架体系 Kubernetes是一个用于容器编排和管理的开源平台,它...
- 2020-11-20 02:07weixin_39769627的博客 这篇文章介绍的内容是关于PHP 经典面试题集 PHP 经典面试题集,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下八重樱:腾讯T3-T4标准精品PHP架构师教程目录大全,只要你看完保证薪资上升一个台阶...
- 2020-11-20 02:07weixin_39639622的博客 结合我自己这段时间的面试情况,面对的一些php面试题列举出来,基本上结合自己...post 一般向服务端提交数据get 传输的参数在 url 中,传递参数大小有限制,post 没有大小限制,get 不安全,post 安全性比get高get请...
- 2018-09-07 08:57遇见你们都是大事《- -》的博客 PHP7 已经出来1年了,PHP7.1也即将和...在这里整理 PHP 5.1 ,PHP5.2,PHP5.3,PHP5.4,PHP5.5,PHP5.6 ,PHP7,PHP7.1 所有新特性,已备大家学习及使用 PHP5.1~PHP5.6 http://blog.csdn.net/fenglailea/article/det...
- 没有解决我的问题, 去提问
联系我们(工作时间:8:30-22:00)
400-660-0108kefu@csdn.net在线客服
- 京ICP备19004658号
- 经营性网站备案信息
公安备案号11010502030143
- 营业执照
- 北京互联网违法和不良信息举报中心
- 家长监护
- 中国互联网举报中心
- 网络110报警服务
- Chrome商店下载
- 账号管理规范
- 版权与免责声明
- 版权申诉
- 出版物许可证
- ©1999-2025北京创新乐知网络技术有限公司