ScotlandPHP 2019


Please answer this simple SPAM challenge: seven plus zero?
(Example: nine)

The Note You're Voting On

9 years ago
Here is a good magazine article (PDF format) that explains the internals of PHP's reference mechanism in detail:

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.

<< Back to user notes page

To Top