Search code examples
phpfunctionreferencepublicstatic-functions

What does prepending '&' to a function name mean in PHP?


I'm using a CMS package written in PHP. In one of it's core files I saw following line that is for defining a function in a class body.

public static function &getLib($sClass, $aParams = array()) {
  // Code
}

I didn't understand why the function name 'getLib' has been prepended with the ampersand(&) sign? I've never seen such thing before.

Can someone please explain me in detail why such thing has been done and what's the benefit it has over simply using the function name?


Solution

  • It means the function should return a reference to a variable rather than just the value itself.