Edit report at http://bugs.php.net/bug.php?id=52245&edit=1
ID: 52245 Comment by: giorgio dot liscio at email dot it Reported by: phpamid at gmail dot com Summary: Private member of parent class accessible from child class. Status: Open Type: Bug Package: *General Issues Operating System: Windows 7 x64 PHP Version: 5.3.2 New Comment: i think that is a bug but i'm not sure if is a php behavior <?php class Father{private $x = 'FATHER'; public function a(){echo $this->x;} } class Son extends Father{private $x = 'SON'; // try to decomment this: //public function a(){echo $this->x;} } $son_instance = new Son; $son_instance->a(); ?> Previous Comments: ------------------------------------------------------------------------ [2010-07-04 13:22:18] phpamid at gmail dot com Description: ------------ <?php class Father { private $my_private_member = 'Father private member'; public function show_private_member() { echo $this->my_private_member; } } class Son extends Father { private $my_private_member = 'Son private member'; } //After init Son object, it has both private members, we can see it if we var_dump($son_instance); $son_instance = new Son; //Following manual php.net the output "Son private member" is expected here, but the result is "Father private member" $son_instance->show_private_member(); ?> Test script: --------------- <?php class Father { private $my_private_member = 'Father private member'; public function show_private_member() { echo $this->my_private_member; } } class Son extends Father { private $my_private_member = 'Son private member'; } //After init Son object, it has both private members, we can see it if we var_dump($son_instance); $son_instance = new Son; //Following manual php.net the output "Son private member" is expected here, but the result is "Father private member" $son_instance->show_private_member(); ?> Expected result: ---------------- Expected "Son private member". ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52245&edit=1