0

Possible Duplicate:
Reference assignment operator in php =&

I saw this example:

function __construct() {
        $this->ci =& get_instance();
    }

What does the =& mean? Is it the same as "set" or something else?

Community
  • 1
  • 1
redconservatory
  • 21,438
  • 40
  • 120
  • 189
  • 2
    possible duplicate of [Reference assignment operator in php =&](http://stackoverflow.com/questions/1768343/reference-assignment-operator-in-php) and [others](http://stackoverflow.com/questions/3737139/reference-what-does-this-symbol-mean-in-php) all linked through from the [tag wiki page](http://stackoverflow.com/tags/php/info) – Quentin Jul 16 '12 at 15:28
  • 2
    If you need to ask this, CodeIgniter is probably not a good choice of framework for you. – DampeS8N Jul 16 '12 at 15:30

1 Answers1

7

It's to assign the value returned by the function as a reference.

nickb
  • 59,313
  • 13
  • 108
  • 143
  • 1
    Just a note for the asker -- it could also be written as `$this->ci = &get_instance();` – ametren Jul 16 '12 at 15:44
  • 1
    Thanks I was looking at the operator page... http://php.net/manual/en/language.operators.php Duh. – redconservatory Jul 16 '12 at 17:07
  • The sad truth in this case actually is that the `&` here is superfluous and is there because of PHP 4 (!) compatbility of Codeigniter. So better not only link the manual but to actually answer the question. By the design of the software, this does nothing. You should not write that `&` in your own code, e.g. your controller classes. – hakre Jul 18 '12 at 08:04