本文整理汇总了PHP中Car::setMake方法的典型用法代码示例。如果您正苦于以下问题:PHP Car::setMake方法的具体用法?PHP Car::setMake怎么用?PHP Car::setMake使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Car
的用法示例。
在下文中一共展示了Car::setMake方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Car
<?php
include 'classes/car.php';
//using public properties
$car1 = new Car();
// $car1 -> make = 'Toyota';
// echo $car1 -> make.'<br />';
//
// $car1 -> make = 'Toyota';
// $car1 -> make = 'Honda';
// echo $car1 -> make.'<br />';
//using a public method
$car1->start();
$car1->setMake('Chevy');
echo $car1->getMake() . '<br />';
//constructors
// $car2 = new Car;
$car2 = new Car('Honda', 'Accord', 'Red');
echo $car2->getColor() . '<br />';
$car3 = new Car('Honda', 'Civic', 'Blue');
echo $car3->getColor() . '<br />';
示例2: setImage
return $this->miles;
}
function setImage($new_image)
{
$this->image = $new_image;
}
function getImage()
{
return $this->image;
}
}
$first_car = new Car("Honda CRV", 12000, 150000, "img/jetta.jpg");
$second_car = new Car("Tesla S", 53000, 20000, "img/tesla.jpg");
$third_car = new Car("Deron's Highschool Volvo", 5000, 170000, "img/volvo.jpg");
$fourth_car = new Car("Jeep Cherokee", null, 68000, "img/cherokee.jpg");
$first_car->setMake("VW Jetta");
$second_car->setMiles(35000);
$third_car->setPrice(5800);
$cars = array($first_car, $second_car, $third_car, $fourth_car);
$cars_matching_search = array();
foreach ($cars as $car) {
$car_price = $car->getPrice();
$car_miles = $car->getMiles();
if (empty($_GET["price"])) {
if ($car_miles < $_GET["mileage"]) {
array_push($cars_matching_search, $car);
}
} elseif (empty($_GET["mileage"])) {
if ($car_price < $_GET["price"]) {
array_push($cars_matching_search, $car);
}