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.
php operators help
Moderator: General Moderators
- hypedupdawg
- Forum Commoner
- Posts: 74
- Joined: Sat Apr 10, 2010 5:21 am
Re: php operators help
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 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!
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 would still be interested in seeing your code!