Re: Only variables or references can be returned by reference
| From: | Daniel Convissor | Date: | Wed, 21 Jan 2004 04:08:57 +0000 |
| Subject: | Re: Only variables or references can be returned by reference | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-7212@lists.php.net to get a copy of this message | ||
Hi Folks:
I'm sorry to be a pest. I'm very close to releasing the next version of
the PEAR DB package and need an answer to this in order to complete the
fixes.
Thanks,
--Dan
On Wed, Jan 14, 2004 at 02:46:25PM -0500, Daniel Convissor wrote:
> Hi Andi:
>
> On Mon, Jan 12, 2004 at 06:31:03PM +0200, Andi Gutmans wrote:
> > That should be fine. The following isn't:
> >
> > function foo() {
> > $x = 1;
> > return $x;
> > }
> >
> > function &bar() {
> > return foo();
> > }
> >
> > Note: foo isn't returning by reference.
>
> Good. Can I ask one final clarification, please? Then the following
> should be koser in PHP 4 and 5, right?
>
> function &execute() {
> return new DB_result();
> }
>
> Or would we need to do this to ensure proper opration in both versions?
>
> function &execute() {
> $tmp =& new DB_result();
> return $tmp;
> }
>
> Or does the answer depend on what the constructor method does? Or...?
>
> Thanks,
>
> --Dan
--
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409