NYCPHP Meetup

NYPHP.org

[nycphp-talk] Change in magic method + reference behavior?

Jake McGraw jmcgraw1 at gmail.com
Sat Jul 19 22:55:47 EDT 2008


> > 1. You're using "Call-time pass-by-reference" by marking your return
> value
> > with an ampersand, try changing your code to this:
> >
> > public function __get($field) {
> >   return &$this->_data[$field];
> > }
>
> But I don't want the default behavior to be to return a reference.
>
> Mike
>

Ah, well, you're setting yourself up for some fun debugging later on, it's
probably best not to mix and match pass by reference/value, which is why I
think the PHP group depreciated the ability to do call-time pass by
reference. IMO, whether a function returns a reference or a value should be
part of the object method definition, not on the basis of the way the
function was called.

- jake


>
> --
> Michael B Allen
> PHP Active Directory SPNEGO SSO
> http://www.ioplex.com/
> _______________________________________________
> 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/20080719/2d3b242e/attachment.html>


More information about the talk mailing list