Site icon DataFlair

PHP OOPs Access Specifiers

Program 1

<html>
<head><title>Demo Access Specifier</title></head>
<body>
    <center>
<?php 
         class Base
         {
                protected $rno=101;
                protected $name="Rajesh Verma";
                protected $course="MTech";
         }
      // is A Relation
          class Derived extends Base
         {
             public function display()
             {
                 echo $this->rno;
                 echo $this->name;
                 echo $this->$course;
             }
                          
         }


         $d=new Derived();
         $d->display();
?>
</center>
</body>
</html>

 

Exit mobile version