class Person
{
public function pub()
{
echo 'I am Publicly accessible<br>';
}
private function pri()
{
echo 'I am Private function<br>';
}
protected function pro()
{
echo 'I am Protected function<br>';
}
}
$person = new Person;
$person->pub(); // output is I am Publicly accessible
$person->pri(); // Fatal error: Call to private method Person::pri()
$person->pro(); // Fatal error: Call to protected method Person::pro()
{
public function pub()
{
echo 'I am Publicly accessible<br>';
}
private function pri()
{
echo 'I am Private function<br>';
}
protected function pro()
{
echo 'I am Protected function<br>';
}
}
$person = new Person;
$person->pub(); // output is I am Publicly accessible
$person->pri(); // Fatal error: Call to private method Person::pri()
$person->pro(); // Fatal error: Call to protected method Person::pro()
No comments:
Post a Comment