当前位置: 首页>>代码示例>>PHP>>正文


PHP Car::getType方法代码示例

本文整理汇总了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();
开发者ID:raynaldmo,项目名称:php-education,代码行数:15,代码来源:index.php

示例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();
开发者ID:nikhilbhatnagar,项目名称:samplePHP,代码行数:29,代码来源:Car.php


注:本文中的Car::getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。