php operators help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
loon5131
Forum Newbie
Posts: 1
Joined: Fri May 14, 2010 3:17 am

php operators help

Post 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.
User avatar
hypedupdawg
Forum Commoner
Posts: 74
Joined: Sat Apr 10, 2010 5:21 am

Re: php operators help

Post 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!
Post Reply