overwrite private class members in php5?

From: Date: Fri, 29 Jul 2005 10:01:25 +0000
Subject: overwrite private class members in php5?
Groups: php.general 
Request: Send a blank email to php-general+get-219583@lists.php.net to get a copy of this message
Hi, I've done something like this: class MyClass { private $var; function __construct($value) {
    $this->var = $value;
} public function printVar() {
    echo($this->var);
} } $object = new MyClass('1'); $object->printVar(); // prints 1 $object->var = 3; // Fatal Error as expected $object->$var = 2; // no error msg $object->printVar(); // prints 2 Hows that possible or what's the difference between $object->var and $object->$var ? thanks in advance for your help! Norbert

« previous php.general (#219583) next »