php – 函数和&函数之间的区别

参见英文答案 > What does it mean to start a PHP function with an ampersand?                                    3个
>            Reference — What does this symbol mean in PHP?                                    18个

function fun1();
function &fun1();

这些有什么区别?

解决方法:

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

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 Manual on Returning References.

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...