本文整理汇总了PHP中Car::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP Car::getType方法的具体用法?PHP Car::getType怎么用?PHP Car::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Car
的用法示例。
在下文中一共展示了Car::getType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Car
<?php
/**
* Copyright (c) 2014 Keith Casey
*
* This code is designed to accompany the lynda.com video course "Design Patterns in PHP"
* by Keith Casey. If you've received this code without seeing the videos, go watch the
* videos. It will make way more sense and be more useful in general.
*/
include_once 'vehicle.php';
$car = new Car(4);
echo $car->getType();
echo '<br />';
$truck = new Truck(18);
echo $truck->getType();
示例2: __construct
include "Vehicle.php";
class Car extends Vehicle
{
private $noOfDoors;
private $color;
private $brand;
public function __construct($cc, $hp, $noOfDoors, $color, $brand)
{
echo "<br/>Hi from car constructor";
parent::__construct('Car', $cc, $hp);
$this->noOfDoors = $noOfDoors;
$this->color = $color;
$this->brand = $brand;
}
public function getColor()
{
return $this->color;
}
public function getNoOfDoors()
{
return $this->noOfDoors;
}
public function getBrand()
{
return $this->brand;
}
}
$v = new Car(1.3, 100, 4, 'Golden', 'BMW');
echo "<br/>Type is " . $v->getType() . ", CC : " . $v->getCc() . ", HP : " . $v->getHp() . ", Color : " . $v->getColor() . ", Brand : " . $v->getBrand();