I am trying to store a collection of objects and can't call object methods in a foreach loop. This is basically what I have. The print function prints nothing. Is there something I am over looking or is this not the way to go about it?
class person
{
private $name;
public function __construct($name) {
$this->name = $name;
}
public function get_name() {
return $this->name;
}
}
$test_set[] = new person("John");
$test_set[] = new person("Jane");
foreach($test_set as $set_item) {
print $set_item->get_name();
}
__construct()...