alexandrheathen

Интефейсы PHP

Jan 29th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1. <?php
  2.  
  3. interface Vehicle {
  4.     public function info ();
  5. }
  6.  
  7. interface Car extends Vehicle {
  8.     public function drive ();
  9. }
  10.  
  11. interface Plane extends Vehicle {
  12.     public function fly ();
  13. }
  14.  
  15. class BMW implements Car {
  16.     public function drive(){
  17.         echo 'Brrrrm...';
  18.     }
  19.  
  20.     public function info () {
  21.         echo '<h1>About BMW</h1>';
  22.     }
  23. }
  24.  
  25. class SuperCar implements Car, Plane{
  26.  
  27.     public function info () {
  28.         echo '<p>Short info</p>';
  29.     }
  30.  
  31.     public function drive () {
  32.         echo '<p>Brrrrmmmm...</p>';
  33.     }
  34.  
  35.     public function fly () {
  36.         echo '<p>Ready to fly!</p>';
  37.     }
  38. }
  39.  
  40. $sc = new SuperCar();
  41. $sc->info();
  42. $sc->drive();
  43. $sc->fly();
Advertisement
Add Comment
Please, Sign In to add comment