Hallo,
Autsch. Es ist wirklich so nicht in PHP implementiert.
Ich kann es gar nicht glauben!
Siehe http://de.php.net/language.oop5.visibility
Oder hier auch ein Auszug:
Quelle: http://www.i-marco.nl/weblog/pivot/entry.php?id=21
A protected method can only be called from code within the original class like with private methods, but also from code in classes that extend the one the protected method was defined in:
Class clsDemo {
protected function protectedMethod() {
return "protected method was called";
}
}
Class clsExtends extends clsDemo {
function printOut() {
return $this->protectedMethod();
}
}
$objDemo = new clsExtends();
echo $objDemo->printOut();
$objDemo2 = new clsDemo();
echo $objDemo2->protectedMethod();
The class will probably speak for itself. When we call the printOut() method of the extending class we will see the output without any problem. However when trying to call protectedMethod() from the outside like we are doing in the last line of this example, PHP will throw an error:
PHP Fatal error: Call to protected method clsDemo::protectedMethod() from context ''
Private and protected members and methods were a long awaited feature for PHP. It brings PHP a lot closer to languages like JAVA and the UML modeling language. But this isn't everything, not even by far!
<<<
So ein Mist aber auch.