NYCPHP Meetup

NYPHP.org

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

Jake McGraw jmcgraw1 at gmail.com
Mon Nov 19 13:28:56 EST 2007


I believe pass-by-reference is now noted in function definitions ala:

function myFunc(&$myvar) {/* Function */}

whereas in PHP4, you could force pass-by-reference at runtime using:

myFunc(&$myvar);

This was depreciated because parameter definitions should be maintained in
the function definition, not in the function call. Whether a parameter is
pass-by-reference or value should be the same  across all calls to maintain
consistency and reduce code (one ampersand instead of many).

- jake


On Nov 19, 2007 1:11 PM, Cliff Hirsch <cliff at pinestream.com> wrote:

>  The php manual says:
>
> "In recent versions of PHP you will get a warning saying that "Call-time
> pass-by-reference" is deprecated when you use a & in foo(&$a);"
>
> Why is this? Besides being ugly, difficult to understand and not very
> elegant, is there any reason technical reason why this is deprecated?
>
> Cliff
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20071119/3295a5f7/attachment.html>


More information about the talk mailing list