lxy777 发表于 2017-3-21 09:16:07

PHP引用的用法

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 willmake 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手册 语言参考/引用的解释 评论
页: [1]
查看完整版本: PHP引用的用法