class test
{
function test_class()
{
echo "<h1>by default function is public visibility </h1>";
}
function add_num($n1,$n2)
{
return $n1+$n2;
}
private function test_private()
{
echo "<h2> For making private function private keyword is used </h2>";
}
function access_private()
{
$this->test_private();
}
}
$ob=new test();
$ob->test_class();
echo "<h1>" . $ob->add_num(5,10) . "</h1>";
echo "<h2> Aceessing private function using public function access_private</h2>";
echo $ob->access_private();
{
function test_class()
{
echo "<h1>by default function is public visibility </h1>";
}
function add_num($n1,$n2)
{
return $n1+$n2;
}
private function test_private()
{
echo "<h2> For making private function private keyword is used </h2>";
}
function access_private()
{
$this->test_private();
}
}
$ob=new test();
$ob->test_class();
echo "<h1>" . $ob->add_num(5,10) . "</h1>";
echo "<h2> Aceessing private function using public function access_private</h2>";
echo $ob->access_private();
No comments:
Post a Comment