Re: Passing a class through an array

From: Date: Fri, 09 Mar 2007 07:13:44 +0000
Subject: Re: Passing a class through an array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-250149@lists.php.net to get a copy of this message
Jeff Taylor wrote:
Hey all, I'm very new to programming and PHP. I want to pass instances of a class through an array, and then use a foreach later to grab details of each class at once... but it returns a fatal error Code: $me = new Toon('Toon1','1') $him = new Toon('Toon2','0') $characterListing = array($me, $him); foreach ($characterListing as $name1) {
    if ($name1->GetIsPlayer())
    {
     echo "<b>Name: </b> ".$name1->$name;//.... etc etc etc
did you mean to use $name1->$name or was it suppose to be $name->name
???
    }
} the error I get is: Fatal error: Cannot access empty property in c:\Inetpub\wwwroot\MyProjects\SecondOffering\htmlFns.php on line 140 Can anyone help? Thanks, Jeff


« previous php.general (#250149) next »