开发者

where to put & in php?

开发者 https://www.devze.com 2022-12-20 13:18 出处:网络
i wonder where i should put the & properl开发者_开发百科y. $b =& $a; or $b = &$a; Both reference the same thing, just a matter of coding style.

i wonder where i should put the & properl开发者_开发百科y.

$b =& $a;
or
$b = &$a;


Both reference the same thing, just a matter of coding style.

Personally, I prefer the $b = &$a style for readability, the space from the & and $ throws me off.


This is actually up to you.

I would, like most others, put the & directly before the $ sign of the variable - it makes the code easier to read in my opinion.


Put it where the code convention you use tells you to put it.

The PHP manual on references uses =& exclusively, whereas the PHP manual on variables states

To assign by reference, simply prepend an ampersand (&) to the beginning of the variable which is being assigned (the source variable).

0

精彩评论

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

关注公众号