Advertisement
bappy7706

Object Oriented PHP (Inheritence-2)

Jun 2nd, 2020
1,410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  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 (Inheritence-2)</h1>
  12. <br>
  13. <?php
  14.  
  15.  
  16.  
  17. class One
  18. {
  19.     public $a;
  20.     public $b;
  21.  
  22.     public function getValue($x,$y)
  23.     {
  24.         $this->a=$x;
  25.         $this->b=$y;
  26.  
  27.     }
  28. }
  29.  
  30.  
  31. class Two extends One
  32. {
  33.     public function display()
  34.     {
  35.         echo "Value of A is : $this->a <br>";
  36.         echo "Value of B is : $this->b <br>";
  37.  
  38.     }
  39.  
  40. }
  41.  
  42.  
  43. $obj=new Two;
  44. $obj->getValue(7706,8084);
  45. $obj->display();
  46.  
  47. ?>
  48.  
  49. </body>
  50. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement