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.
22 lines
507 B
22 lines
507 B
<?php
|
|
//这是一个抽象类
|
|
abstract class animal
|
|
{
|
|
public $eyes = 2;
|
|
public $foots = 4;
|
|
abstract public function eat(); //抽象方法
|
|
}
|
|
|
|
class dog extends animal //继承抽象类
|
|
{
|
|
public function eat() //子类必须实现抽象类中的抽象方法
|
|
{
|
|
echo "狗吃骨头".'<br>';
|
|
}
|
|
}
|
|
|
|
$adog = new dog();
|
|
$adog -> eat();
|
|
|
|
//注意:抽象类不能被实例化,已经要被子类继承
|
|
?>
|