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.

Andi

At 11:12 AM 1/12/2004 -0500, Daniel Convissor wrote:
On Mon, Jan 12, 2004 at 06:06:22PM +0200, Andi Gutmans wrote:
> At 10:39 AM 1/12/2004 -0500, Daniel Convissor wrote:
> >On Mon, Jan 12, 2004 at 09:05:12AM +0200, Andi Gutmans wrote:
> >>
> >> b) A function which returned a variable by reference couldn't be returned
> >> by reference. I think this one is probably OK to code.
> >
> >But, does this cause memory corruption problems in PHP 4?
>
> If it's returned by reference consistently then I believe it doesn't.


I'm uncertain what you mean. For example, I'm guessing this is NOT okay?

function &foo() {
    $x = 1;
    return $x;
}

function &bar() {
    return foo();
}

function blah() {
    // problem in PHP 4 because this isn't returning by reference?
    return foo();
}

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

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to