Re: Returning an object
| From: | Justin Patrin | Date: | Fri, 07 May 2004 16:29:15 +0000 |
| Subject: | Re: Returning an object | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-185645@lists.php.net to get a copy of this message | ||
Aidan Lister wrote:
How _should_ this be done? In terms of "best practice". <?php function foobar () {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>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.