# Fwd: Re:  Only variables or references can be returned by reference

- Thread: https://externals.io/message/7475
- Original archive: https://news-web.php.net/php.internals/7475
- Started by Daniel Convissor on 2004-02-02T17:05:58+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #7475 — Daniel Convissor — 2004-02-02T17:05:58+00:00

URL: https://externals.io/message/7475#7475

Hi:

This continues to slip between the cracks.  Can someone please answer it?

Thanks,

--Dan

----- Forwarded message from Daniel Convissor <danielc@analysisandsolutions.com> -----

From: Daniel Convissor <danielc@analysisandsolutions.com>
To: PHP Internals List <internals@lists.php.net>
Date: Wed, 14 Jan 2004 14:46:25 -0500
Subject: Re: [PHP-DEV] Only variables or references can be returned by reference

Hi Andi:


> 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...?

----- End forwarded message -----

-- 
 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

---

## #7488 — Andi Gutmans — 2004-02-02T19:43:57+00:00

URL: https://externals.io/message/7475#7488 · In reply to: #7475

Without checking it more thoroughly, I think the former and the latter 
should work with both PHP 4 and PHP 5. If you want to be 100% certain then 
the latter will definitely work but I think we allowed the former in PHP 4 
too (in a hackish way).
Don't sue me if I'm wrong :)

Andi

At 12:05 PM 2/2/2004 -0500, Daniel Convissor wrote:
>Hi:
>
>This continues to slip between the cracks.  Can someone please answer it?
>
>Thanks,
>
>--Dan
>
>----- Forwarded message from Daniel Convissor 
><danielc@analysisandsolutions.com> -----
>
>From: Daniel Convissor <danielc@analysisandsolutions.com>
>To: PHP Internals List <internals@lists.php.net>
>Date: Wed, 14 Jan 2004 14:46:25 -0500
>Subject: Re: [PHP-DEV] Only variables or references can be returned by 
>reference
>
>Hi Andi:
>
>
> > […]
>
>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...?
>
>----- End forwarded message -----
>
>--
>  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
