note 31257 added to functions.returning-values
| From: | kiteced at hotmail dot com | Date: | Tue, 15 Apr 2003 14:15:29 +0000 |
| Subject: | note 31257 added to functions.returning-values | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-46645@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..
--
http://www.php.net/manual/en/functions.returning-values.php
http://master.php.net/manage/user-notes.php?action=edit+31257
http://master.php.net/manage/user-notes.php?action=delete+31257
http://master.php.net/manage/user-notes.php?action=reject+31257