Page 1 of 1
php operators help
Posted: Fri May 14, 2010 3:26 am
by loon5131
can anyone explain this operator =&
i know & is bitwise operator, but if combine with = , what the mean become?
cause i see CI code always use this =& operators, i am wondering about this.
Re: php operators help
Posted: Fri May 14, 2010 3:48 am
by hypedupdawg
Could you provide an example? Even just a few lines of code would be great.
EDIT: I did find the answer; Google really dosn't like you entering operators in its search... anyway:
As far as I can make out, =& means
reference to another variable. So this means that if you change one variable, the other variable changes with it, not just once but for the rest of the script, e.g
Code: Select all
<?php $a = "This is var A";
$b = "This is var B";
$b =& $a; // referencing $b to $a
echo $b; //echos "This is var A"
$a = "This has been changed"; //this will change both $a and $b
echo $b . " too"; //echos "This has been changed too"
?>
I found the information
here on php.net: I don't fully understand when you would want to use it, as presumably you could just echo the original variable. I'm sure others will have some suggestions for you.
I would still be interested in seeing your code!