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


PHP Car::Display_all方法代码示例

本文整理汇总了PHP中Car::Display_all方法的典型用法代码示例。如果您正苦于以下问题:PHP Car::Display_all方法的具体用法?PHP Car::Display_all怎么用?PHP Car::Display_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Car的用法示例。


在下文中一共展示了Car::Display_all方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Car

$car1->set_milage(15);
$car1->Display_all();
echo "<br>";
$car2 = new Car();
$car2->set_price(2000);
$car2->set_speed(5);
$car2->set_fuel(0);
$car2->set_milage(105);
$car2->Display_all();
echo "<br>";
$car3 = new Car();
$car3->set_price(2000);
$car3->set_speed(35);
$car3->set_fuel(50);
$car3->set_milage(20);
$car3->Display_all();
echo "<br>";
$car4 = new Car();
$car4->set_price(2000000);
$car4->set_speed(200);
$car4->set_fuel(75);
$car4->set_milage(30);
$car4->Display_all();
echo "<br>";
$car5 = new Car();
$car5->set_price(2000);
$car5->set_speed(40);
$car5->set_fuel(100);
$car5->set_milage(45);
$car5->Display_all();
echo "<br>";
开发者ID:vmshalkey,项目名称:php_oop_vehicles,代码行数:31,代码来源:car.php

示例2: Display_all

        $this->mileage = $mileage;
        if ($price > 10000) {
            $this->tax = 0.15;
        } else {
            $this->tax = 0.12;
        }
    }
    //methods
    public function Display_all()
    {
        echo "Price: {$this->price}\n";
        echo "Speed: {$this->speed}\n";
        echo "Fuel: {$this->fuel}\n";
        echo "Mileage: {$this->mileage}\n";
        echo "Tax: {$this->tax}\n\n";
    }
}
$obj1 = new Car(2000, 35, 'Full', 15);
// price and max speed.
$obj2 = new Car(2000, 5, 'Not Full', 105);
$obj3 = new Car(2000, 15, 'Kind of Full', 95);
$obj4 = new Car(2000, 25, 'Full', 25);
$obj5 = new Car(2000, 45, 'Empty', 25);
$obj6 = new Car(20000000, 35, 'Empty', 15);
echo $obj1->Display_all();
echo $obj2->Display_all();
echo $obj3->Display_all();
echo $obj4->Display_all();
echo $obj5->Display_all();
echo $obj6->Display_all();
开发者ID:jreyles,项目名称:lamp-stack,代码行数:30,代码来源:car.php


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