Posted by Pablo Godel on 10/21/05 23:42
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
[Back to original message]
|