note 73556 deleted from language.oop5.visibility by danbrown
| From: | danbrown@php.net | Date: | Fri, 21 Nov 2008 20:18:22 +0000 |
| Subject: | note 73556 deleted from language.oop5.visibility by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-146805@lists.php.net to get a copy of this message | ||
Note Submitter: atitthaker at gmail dot com
----
<?
class A
{
protected $b=20;
private $a=10;
//protected method and shall not be accessible under class C
protected function access()
{
print("here");
}
}
class B extends A
{
public function test()
{
$this->access() ;
}
}
class C extends B
{
function temp()
{
$this->access(); // access variable and prints "here"
}
}
$abc= new C();
$abc->temp();
?>
Above code shall generate error as protected method of class A is accessible in class C which is
directly not inheriting class A.