You are here: private properties problem « PHP « IT news, forums, messages
private properties problem

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация