I am can't figure out why this doesn't work:
class Test
{
public static $arData=array();
public static function addMember(Person $member)
{
self::$arData[]=$member;
}
public static function showAll()
{
for($i=0;$i<count(self::$arData);$i++)
{
self::$arData[i]->show();
}
}
}
What I get is this: Fatal error: Call to a member function show() on a non-object
.
The show()
method does exist and it basically prints out name and location of a person.
In in the constructor, instead of adding $member to $arData I do $member->show() it works.
So... what's up?