本文整理匯總了PHP中Driver::drive方法的典型用法代碼示例。如果您正苦於以下問題:PHP Driver::drive方法的具體用法?PHP Driver::drive怎麽用?PHP Driver::drive使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Driver
的用法示例。
在下文中一共展示了Driver::drive方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testDriver
public function testDriver()
{
$dirver = new Driver();
$dirver->drive(new Bmw());
}
示例2: drive
}
function drive()
{
echo $this->name . "正在開車" . "<br>";
}
}
// 醫生子類
class Doctor extends Person
{
private $hospital, $department;
function __construct($name = "", $age = "", $sex = "", $height = "", $hospital = "", $department = "")
{
parent::__construct($name, $age, $sex, $height);
$this->hospital = $hospital;
$this->department = $department;
}
function treat()
{
echo $this->name . "正在為病人治療" . "<br>";
}
}
// 人 類實例化
$person1 = new Person("張三", 20, "男", 180);
$person1->talk();
$person1->walk();
// 司機類實例化
$driver1 = new Driver("李四", 30, "男", 175, 8);
$driver1->drive();
// 醫生類實例化
$doctor1 = new Doctor("王麗", 25, "女", 167, "中國醫科大學", "兒科");
$doctor1->treat();