Hi guys,
I am newbie in PHP5 and I am confused about the access of protected items.According to the tutorial "Protected limits access to inherited classes (and to the class that defines the item).", but it is possible too to access a protected item from the parent.Can anyone explain me how it is possible?
Thanks in advance.
Hier is an example of working code:
class A {
public function publicFunction(A $obj) {
echo $obj->attribut;
echo '<br />';
$obj->protectedFunction();
}
}
class B extends A {
protected $attribut = 'I am protected attribut';
protected function protectedFunction() {
echo 'In protected function';
}
public function testPublic() {
return parent :: publicFunction($this);
}
}
$instanceB = new B;
$instanceB->testPublic();
exit;