SHARE
TWEET

Object Oriented PHP (Hierachical Inheritence)

bappy7706 Jun 2nd, 2020 567 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport"
  6.           content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  7.     <meta http-equiv="X-UA-Compatible" content="ie=edge">
  8.     <title>Document</title>
  9. </head>
  10. <body>
  11. <h1 style="text-align: center;color: maroon;font-weight: bold; font-family: 'Mongolian Baiti'"> Object Oriented PHP (Hierachical Inheritence)</h1>
  12. <br>
  13. <?php
  14.  
  15.  class Math
  16.  {
  17.      public $a;
  18.      public $b;
  19.      public function getV($x,$y)
  20.      {
  21.          $this->a=$x;
  22.          $this->b=$y;
  23.  
  24.  
  25.  
  26.      }
  27.  
  28.  }
  29.  
  30.  
  31.  class Ad extends  Math
  32.  {
  33.      public $c=20;
  34.      public $sum;
  35.  
  36.  
  37.      public function add()
  38.      {
  39.       return $this->sum=    $this->a+$this->b+$this->c;
  40.      }
  41.  
  42.  
  43.      public function  disp()
  44.      {
  45.          echo "Value of A is : $this->a <br>";
  46.          echo "Value of B is : $this->b <br>";
  47.          echo "Value of C is : $this->c <br>";
  48.          echo "Value of Addition is : " .$this->add(); echo "<br/>";
  49.  
  50.      }
  51.  
  52.  
  53.  
  54.  }
  55.  
  56.  class Ml extends Ad
  57.  {
  58.  
  59. public  $Msum;
  60.   public function mul()
  61.   {
  62. return $this->Msum = $this->a * $this->b * $this->c;
  63.   }
  64.  
  65.  public function disp()
  66.  {
  67.       echo "Value of Multiplication is: ". $this->mul();
  68.  }
  69.  
  70.  
  71.  }
  72.  
  73.  
  74.  $oba= new Ad;
  75.  $oba->getV(5,6);
  76.  $oba->disp();
  77.  $obm = new Ml;
  78. $obm->getV(5,6);
  79.  $obm->disp();
  80.  
  81.  
  82.  
  83. ?>
  84.  
  85. </body>
  86. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top