用“&"号启动PHP函数意味着什么? [英] What does it mean to start a PHP function with an ampersand?
问题描述
我正在使用Facebook库,其中包含以下代码:
I'm using the Facebook library with this code in it:
class FacebookRestClient {
...
public function &users_hasAppPermission($ext_perm, $uid=null) {
return $this->call_method('facebook.users.hasAppPermission',
array('ext_perm' => $ext_perm, 'uid' => $uid));
}
...
}
&是什么?函数定义的开头,以及如何使用这样的库(在一个简单的示例中)
What does the & at the beginning of the function definition mean, and how do I go about using a library like this (in a simple example)
推荐答案
函数名称前的与号表示该函数将返回对变量的引用而不是值.
An ampersand before a function name means 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屋!