how to access class members
| From: | Alexander Schunk | Date: | Tue, 04 May 2010 13:02:24 +0000 |
| Subject: | how to access class members | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-30069@lists.php.net to get a copy of this message | ||
Hello,
i have a question:
How to access class members?
I have the following class definition:
class Mitarbeiter{
public $name = 'meier';
public $alter = '50';
public $gehalt = '2000';
public $abteilung = 'programmierung';
function printMember(){
echo 'Name: ' . $this->public;
echo 'Alter: ' . $this->public;
echo 'Gehalt: ' . $this->public;
echo 'Abteilung: ' . $this->public;
}
}
Now i want to access the public member with:
$m = new Mitarbeiter();
$m->printMember();
When calling method printMember() i get an error "cannot access empty
class member".
I dont see why the class members are empty?
Regards
Alexander