首页 > 代码库 > 面向对象实战
面向对象实战
<?php
header("content-type:text/html;charset=utf8");
interface lidepeng{
public function lidepeng($name);
}
class depeng implements lidepeng{
private $name;
private $height;
private $weight;
public function lidepeng($name){
echo "eat rice".$this->name=$name;
echo "\n";
echo "<br/>";
}
public static function person(){
echo "我是一个人";
}
}
class peng implements lidepeng{
public function lidepeng($name){
echo "eat fruit".$this->name=$name."\n";
echo "\n";
echo "<br/>";
}
public function __destruct(){
echo "你好 "."\n"."</br>"."HellowWord";
echo "\n";
echo "<br/>";
}
}
class son extends depeng{
public function getname($name,$height){
echo $this->name=$name;
echo $this->height=$height;
}
}
$name=new depeng();
$name->lidepeng("lidepeng");
$name1=new peng();
$name1->lidepeng("lide");$son=new son();
$son->getname("haha","180");
echo depeng::person();
面向对象实战