returning array of objects
| From: | Oleg Timofeyev | Date: | Fri, 21 Jul 2000 09:41:31 +0000 |
| Subject: | returning array of objects | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-7537@lists.php.net to get a copy of this message | ||
Hi I have an object that is initialized inside of the function as an array.
Than this array of objects is returned.
Here is how I call the function with an object in it;
$obj = get_info_function($idsarray);
Than I return the array of objects like so, after ofcourse info is moved in
there using for loop and
........
$object[$i] = new information($arr[0],$arr[1]);
........
return($object)
Here is the problem, when I try to access the variables using get in
$obj[1]->get_userid() and ->get_first_name I get values only for first_name.
And when I try to pass more variables to the object with ofcourse
appropriate get functions, ONLY the last one that I passes gets returned. I
dont get whats the problem, any ideas? Again process is, main programm calls
function which initializes array of objects and returns them. I can access
any object in an array but only one value.
class information
{
var $user,$first;
function information($user_id,$first_name)
{
$this->$user = $user_id;
$this->$first = $first_name;
}
function get_userid()
{
return $this->$user;
}
function get_firstname()
{
return $this->$first;
}
}