NYCPHP Meetup

NYPHP.org

[nycphp-talk] Why is pass-by-reference deprecated?

Chuck Hagenbuch chuck at horde.org
Wed Nov 21 13:03:31 EST 2007


Quoting Urb LeJeune <urb at e-government.com>:

>         There are two types of calls.
>
> 1. Call by value
> 2. Call by reference
>
>         Unless PHP does things differently than any other language that
> I have ever used

Apparently it does. You should read up on reference counting, which is  
what PHP does in most situations (for example, objects in PHP 5 are  
pass-by-reference always) for pass-by-value. Nothing is copied unless  
you actually change the value. This makes pass-by-reference actually  
slightly _slower_ in some cases when you are passing an array into a  
function where you will not change the array.

-chuck



More information about the talk mailing list