You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
507 B

3 years ago
  1. <?php
  2. //这是一个抽象类
  3. abstract class animal
  4. {
  5. public $eyes = 2;
  6. public $foots = 4;
  7. abstract public function eat(); //抽象方法
  8. }
  9. class dog extends animal //继承抽象类
  10. {
  11. public function eat() //子类必须实现抽象类中的抽象方法
  12. {
  13. echo "狗吃骨头".'<br>';
  14. }
  15. }
  16. $adog = new dog();
  17. $adog -> eat();
  18. //注意:抽象类不能被实例化,已经要被子类继承
  19. ?>