Overload of private atributes ?

From: Date: Thu, 04 Dec 2003 16:28:57 +0000
Subject: Overload of private atributes ?
Groups: php.general 
Request: Send a blank email to php-general+get-171850@lists.php.net to get a copy of this message
Do we have a way to avoid the overload of private atribute members? Look the example below, and you will see that as the private member is not visible in the subclass, it is overloaded by an atribute member of the same name. How to avoid that?????? class PrivateAccess { private $privateVar; // public $privateVar; // protected $privateVar; public function set($var) { $this->privateVar = $var; } } class subClassPrivateAccess extends PrivateAccess { function test() { $this->privateVar = 10; } } $acesso = new subClassPrivateAccess; $acesso->set(5); $acesso->test(); print_r($acesso); var_dump($acesso); =========== Results: PUBLIC: ========== subclassprivateaccess Object ( [privateVar] => 10 ) object(subclassprivateaccess)#1 (1) { ["privateVar"]=> int(10) } PROTECTED: ========== subclassprivateaccess Object ( [privateVar:protected] => 10 ) object(subclassprivateaccess)#1 (1) { [""]=> int(10) } PRIVATE: ========== subclassprivateaccess Object ( [privateVar] => 10 [privateVar:private] => 5 ) object(subclassprivateaccess)#1 (2) { ["privateVar"]=> int(10) [""]=> int(5) } __________________________________ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/

« previous php.general (#171850) next »