0

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?

halfer
  • 18,701
  • 13
  • 79
  • 158
  • See this [answer](http://stackoverflow.com/questions/1676897/what-does-it-mean-to-start-a-php-function-with-an-ampersand) – Scriptable Jan 25 '15 at 17:31

1 Answers1

2

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

steve
  • 2,393
  • 1
  • 20
  • 29