功能与功能之间的差异 [英] difference between function and &function

查看:68
本文介绍了功能与功能之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

function fun1();
function &fun1();

这些有什么区别?

推荐答案

如果在函数名称前加上与号,则该函数将返回对变量的引用,而不是值.

If you put an ampersand before your function name, the function will return a reference to a variable instead of the value.

当您想使用函数来引用返回时很有用 查找应将引用绑定到哪个变量.不使用 引用返回以提高性能.引擎会 自行自动优化.仅在以下情况下返回引用 您有充分的技术理由这样做.

Returning by reference is useful when you want to use a function to find to which variable a reference should be bound. Do not use return-by-reference to increase performance. The engine will automatically optimize this on its own. Only return references when you have a valid technical reason to do so.

有关返回引用的PHP手册.

这篇关于功能与功能之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆