Jump to content

What is the purpose of this operator "=&"?


jeboy

Recommended Posts

The & operator is the reference operator. A reference is like an alias - if one variable is a reference to another, then a change to either will result in both changing:

 

<?php
$var = 'foobar';
$var2 = &$var;
$var = 'test';
echo $var2;
?>

The & operator is the reference operator. A reference is like an alias - if one variable is a reference to another, then a change to either will result in both changing:

 

<?php
$var = 'foobar';
$var2 = &$var;
$var = 'test';
echo $var2;
?>

 

In your example ($var2 = &$var), does it differ from $var =& new object(); ? Because it's an assignment operator which instantiate an object and call it $var.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.