<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
</head>
<body>
<?php
class Animal{
public function cry(){
echo "我不知道...<br/>";
}
}
class Dog extends Animal{
public function cry(){
echo "汪汪...<br/>";
}
}
class Pig extends Animal{
public function cry(){
echo "哼哼...<br/>";
}
}
$dog=new Dog();
$dog->cry();
$pig=new Pig();
$pig->cry();
?>
</body>
</html>
简单案例
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
</head>
<body>
<?php
class Animal{
public function cry(){
echo "我不知道...<br/>";
}
}
class Dog extends Animal{
public function cry($dogCry){
echo $dogCry."<br/>";
}
}
$dog=new Dog();
$dog->cry("汪汪");
?>
</body>
</html>