< ?php
class vehicle
{
public $type;
protected $model;
private $color;
function set_type($tt){
$this->type=$tt;
}
function set_model($mm){
$this->model=$mm;
}
function set_color($cc){
$this->color=$cc;
}
function getcartype(){
return $this->type;
}
function getmodel(){
return $this->model;
}
function getcolor(){
return $this->color;
}
}
$Lindacar=new vehicle;
$Lindacar->type="Van";
$Lindacar->set_model("TOYOTA");
$Lindacar->set_color("silver");
echo "Linda的車型是 : ".$Lindacar->getcartype()."< p>";
echo "Linda車的顏色是 : ".$Lindacar->getcolor()."< p>";
echo "Linda車的廠牌是 : ".$Lindacar->getmodel();
?>
==============結果===========
Linda的車型是 : Van
Linda車的顏色是 : silver
Linda車的廠牌是 : TOYOTA
沒有留言:
張貼留言