开发者

where to put & in php?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜