There are three type of visibility scope:
PRIVATE : Variable or function of private scope can be accessed only with in the class they are declared.
PROTECTED:
- See more at: http://findnerd.com/list/view/Visibility-Scope-Of-Variable-And-Functions/3556/
For queries about PHP Programming Questions and Answers
You can also Visit to PHP Developer Forum
- Public
- Private
- Protected
PRIVATE : Variable or function of private scope can be accessed only with in the class they are declared.
PROTECTED:
Variable or function of protected scope can be accessed only by its subclass and derived class.
<?php /** * Define ClassA */ class ClassA { public $a = 1; protected $b = 2; private $c = 3; function detail() { echo $this->a; echo $this->b; echo $this->c; } } $obj = new ClassA(); echo $obj->a; // Works echo $obj->b; // Fatal Error echo $obj->c; // Fatal Error $obj->detail(); // Shows Public, Protected and Private
Variable or function of protected scope can be accessed only by its subclass and derived class.
- See more at: http://findnerd.com/list/view/Visibility-Scope-Of-Variable-And-Functions/3556/
For queries about PHP Programming Questions and Answers
You can also Visit to PHP Developer Forum
No comments:
Post a Comment