dqqt31923 2012-08-06 15:23
浏览 20

如何使PHP 5.4允许通过引用传递调用时间?

Short question:

function Foo(&$FooParam)
{
...
}

Foo(&$Bar);

How to keep this code and make it work in PHP 5.4?

Longer description:

I have quite a lot of PHP code in which I used a notation pattern from C# - mark reference parameters at declaration AND function call. It makes code more readable and prevents mistakes when refactoring code. Now PHP from 5.4 reports this as unsupported call-time pass by reference, which I believe is incorrect (according to php.net, the prohibition of this feature in 5.4 was meant against the caller changing semantics of function parameters. It clearly does not apply in this case).

I still see the code with & at function declaration and call as more readable and want to use it. Is there any way how to make it work in PHP 5.4? If not, please feel free to add some reasoning which would convince me that this C# practice is wrong and I should rewrite all the code so that it will be 5.4-compatible.

Edit: I have read some eight or ten questions on similar topic and the difference is I'm not asking "how to fix code" but "how not to fix code". If there is really no way how to make it working, please state your oppinion on why is it decided to be this way or why I should prefer this "new" way of writing code which (I think) is worse than the "old" way.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
    • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
    • ¥15 MATLAB中streamslice问题
    • ¥15 如何在炒股软件中,爬到我想看的日k线
    • ¥15 seatunnel 怎么配置Elasticsearch
    • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
    • ¥15 (标签-MATLAB|关键词-多址)
    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端
    • ¥15 基于PLC的三轴机械手程序