I found some more information about it here:
http://bugs.php.net/bug.php?id=24687

It looks like you should assign an object to a variable before returning it.


"Justin Patrin" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Aidan Lister wrote:
>
> > How _should_ this be done? In terms of "best practice".
> >
> > <?php
> > function foobar ()
> > {
> >     return new SomeObject;
> > }
> > ?>
> >
> > Or:
> >
> > <?php
> > function barfoo ()
> > {
> >     $tempvar = new SomeObject;
> >     return $tempvar
> > }
> > ?>
> >
> > Please don't reply if you really, really don't know what you are talking
> > about.
>
> Some earlier versions of PHP5 would not allow returning by reference of
> a function call or a new call. It was very recently added, but may not
> be in RC2 (not sure). You had to assign to a variable before you returned.
>
> Here's my 2c:
>
> function &foobar() {
>    return new SomeObject;
> }
>
> -- 
> paperCrane <Justin Patrin>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to