现在的位置: 首页 > 综合 > 正文

PHP引用的用法

2019年10月31日 ⁄ 综合 ⁄ 共 671字 ⁄ 字号 评论关闭

midir (01-Mar-2009 03:44)

Here is a good magazine article (PDF format) that explains the internals of PHP's reference mechanism in detail:http://derickrethans.nl/files/phparch-php-variables-article.pdf

It should explain some of the odd behavior PHP sometimes seems to exhibit, as well as why you can't create "references to references" (unlike in C++), and why you should never attempt to use references to speed up passing of large strings or arrays (it will
make no difference, or it will slow things down).

It was written for PHP 4 but it still applies. The only difference is in how PHP 5 handles objects: passing object variables by value only copies an internal pointer to the object. Objects in PHP 5 are only ever duplicated if you explicitly use the clone keyword.


源自:PHP手册 语言参考/引用的解释 评论

抱歉!评论已关闭.