开发者

PHP equals and operators [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicates:

Reference - What does this symbol mean in PHP?

what do “=&” / “&=” operators in php mean?

Sorry guys I feel like I'm asking too simple of a question but 开发者_如何学Pythonwhat is =& in PHP? I tried to use this group function with ACL in Cakephp...


You use =& when you want to assign a variable by reference. For more information see http://php.net/manual/en/language.references.php.

Example:

$a = array(1, 2, 3);
// $b is a reference to $a.
// If you change $a or $b, the value for both $a and $b will be changed.
$b =& $a;

$c = array(1, 2, 3);
// $d is a copy of $c.
// If you change $d, $c remains unchanged.
$d = $c;


$b = 3;
$a =& $b;
$b = 5; //$a is 5 now
$a = 7; //$b is 7 now
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜