1. In PHP 5, I used an eval statement inside a loop to dynamically construct a group of objects ...
$evalStatement = $objName." = new ".$className."(".$fieldString.");";
eval( $evalStatement );
2. When I echo $evalStatement, the constructors look fine ...
$Teacher_7 = new Teacher('6','Jimmy','Bond','6','Science','6','Sci','Spurs');
$Teacher_8 = new Teacher('7','Tammy','Benson','7','','3','Math','Wranglers');
3. With the object $instanceOfTeacher, I add these objects to an array which tests their "objecthood" (thanks for the code, Nogdog) ...
public function addToArrayTeacher($obj)
{
if(is_a($obj, 'Teacher'))
{
$this->ArrayTeacher[] = $obj;
return(TRUE);
}
else
{
// throw exception or raise error, then:
return(FALSE);
}
}
4. When I use this get_CountArray() function, I get a count of 81 (which the previous step indicates should all be objects)
public function get_CountArray()
{
return count($this->ArrayTeacher);
}
5. But when I try and access these objects by looping through ArrayTeacher...
// Function Call
$instanceOfTeacher->brand_Students( $schoolName, "Band", $corral_band );
// Function Header
public function brand_Students ( $schoolName, $subject, $theCorral )
// Attempt to Access Array Item containing object
if ( $this->get_ArrayTeacher( $i )->get_subjArea() == $subject )
[B]I get this error message ...[/B]
Fatal error: Call to a member function get_subjArea() on a non-object in C:\Program Files\wamp\www\db\classes\Teacher.class.php on line 219
Anyone see what I've done wrong?