[PHP-DEV] Passing by reference From: Andi Gutmans (andi <email protected>)
Date: 11/27/00

Hi,

I just commited a patch which lightens up the restrictions Zeev and I
introduced a few weeks ago in the CVS tree of passing certain arguments to
functions which declare the argument to be passed by reference.
It's a big patch so please try and see if it works.
If you have a function:
function foo(&$a)
{
}
The following can be passed to foo():
a) A variable, i.e. foo($a)
b) A new statement, i.e. foo(new foobar());
c) A reference returned from a function, i.e.:
function &bar()
{
        $a = 5;
        return $a;
}
foo(bar());

All other expressions are undefined and can not be passed by reference.
For example:
a)
function bar() // Note the missing &
{
        $a = 5;
        return $a;
}
foo(bar));

b) foo($a = 5);
c) foo(5);

Please let me know if this solves some of the bugs people have been
reporting with the current CVS tree.

Andi

---
Andi Gutmans <andi <email protected>>
http://www.zend.com/

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>