alexandrheathen

Работа с абстрактными классами

Jan 29th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.42 KB | None | 0 0
  1. <?php
  2.  
  3. abstract class User {
  4.     public $name;
  5.     public $last_name;
  6.  
  7.     /**
  8.      * @param $name
  9.      * @param $last_name
  10.      * @return mixed
  11.      */
  12.     abstract function print_full(); // required
  13. }
  14.  
  15. class Mod extends User{
  16.  
  17.     function print_full () {
  18.         echo $this->last_name.' '.$this->name;
  19.     }
  20. }
  21.  
  22. $mod = new Mod();
  23. $mod->name = 'Htn';
  24. $mod->last_name = 'Pro';
  25. echo '<pre>';
  26. var_dump($mod);
  27. echo '</pre>';
  28. $mod->print_full();
Advertisement
Add Comment
Please, Sign In to add comment