private properties problem
| From: | Pablo Godel | Date: | Fri, 21 Oct 2005 20:42:10 +0000 |
| Subject: | private properties problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-224426@lists.php.net to get a copy of this message | ||
Today I discovered a possible serious problem with the way the latest PHP versions handle private properties.
Given the following code:
<?php
class Base
{
private $var1 = 0;
}
class FinalClass extends Base
{
function Test()
{
$this->var1 = 10;} } $c = new FinalClass(); $c->Test(); print_r( $c ); ?> I get the following result: FinalClass Object ( [var1:private] => 0 [var1] => 10 ) Now... PHP should have displayed an error when I was trying to set a value to this private member from the parent class. No error message was displayed. It created a local member which holded the value 10. But when trying to access this value from the parent class, it is not there. I think PHP should notify of the problem but it is not doing so. I have my error reporting level on E_ALL. Any ideas? Pablo Godel