note 31257 deleted from functions.returning-values by alindeman
| From: | alindeman@php.net | Date: | Tue, 15 Apr 2003 20:40:58 +0000 |
| Subject: | note 31257 deleted from functions.returning-values by alindeman | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-46656@lists.php.net to get a copy of this message | ||
In PHP, only variables can be passed by reference.
I'd like to use references in a class méthod :
class foo
{
var $elts; // a collection of objects
function foo()
{
...
}
function &test($name_elt)
{
foreach($this->elts as $elt)
array_push((array)$tmp,$elt->name);
$offset=array_search($name_elt,$tmp);
return $this->elts[$offset];
}
}
in this way, i could do :
$my_var=new foo();
$tmp=&$my_var->test("MY_ELT_NAME");
Theres's something wrong in this, but i'm sure it could works..