SHARE
TWEET

Object Oriented PHP (Multi Level Inheritence)

bappy7706 Jun 2nd, 2020 663 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 (Multi Level Inheritence)</h1>
  12. <br>
  13. <?php
  14.  
  15.  
  16. class Father
  17. {
  18.  
  19.     public $a;
  20.     public $b;
  21.  
  22.     public function getV($x, $y)
  23.     {
  24.         $this->a = $x;
  25.         $this->b = $y;
  26.  
  27.     }
  28. }
  29.  
  30. class Son extends Father
  31. {
  32. public $c=50;
  33.  
  34.  public $sum;
  35.  public function add()
  36.  {
  37.      return $this->sum =$this->a +$this->b+ $this->c;
  38.  
  39.  }
  40.  
  41. }
  42. class Gson extends Son
  43. {
  44.     public function display()
  45.     {
  46.         echo "Value Of A is : $this->a <br>";
  47.         echo "Value Of B is : $this->b <br>";
  48.         echo "Value Of C is : $this->c <br>";
  49.         echo "Value Of Total Sum is :". $this->add()  ;
  50.  
  51.  
  52.     }
  53.  
  54.  
  55. }
  56.  
  57.  
  58.  $obj =new Gson;
  59. $obj->getV(30,20);
  60. $obj->add();
  61. $obj->display();
  62.  
  63.  
  64.  
  65.  
  66. ?>
  67.  
  68. </body>
  69. </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