本文整理汇总了PHP中Car::getMiles方法的典型用法代码示例。如果您正苦于以下问题:PHP Car::getMiles方法的具体用法?PHP Car::getMiles怎么用?PHP Car::getMiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Car
的用法示例。
在下文中一共展示了Car::getMiles方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: function
$app->get('/', function () use($app) {
return $app['twig']->render('home.html.twig');
});
$app->get('/post', function () use($app) {
return $app['twig']->render('cars.html.twig', array('cars' => Car::getAll()));
});
$app->get("/search", function () use($app) {
return $app['twig']->render('search_cars.html.twig');
});
$app->post("/cars", function () use($app) {
$car = new Car($_POST['model'], $_POST['price'], $_POST['miles'], $_POST['image_path']);
$car->save();
return $app['twig']->render('create_car.html.twig', array('newcar' => $car));
});
$app->post("/delete_car", function () use($app) {
Car::deleteAll();
return $app['twig']->render('delete_cars.html.twig', array('cars' => Car::getAll()));
});
$app->get("/view_car", function () use($app) {
$cars_matching_search = array();
$cars = Car::getAll();
$user_price = $_GET["price"];
$user_miles = $_GET["miles"];
foreach ($cars as $car) {
if ($car->getPrice() < $user_price && $car->getMiles() < $user_miles) {
array_push($cars_matching_search, $car);
}
}
return $app['twig']->render('car_posting.html.twig', array('cars' => $cars_matching_search));
});
return $app;
示例2: array
// Direct app to twig.path
$app = new Silex\Application();
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
// Home page: car search form.
$app->get("/", function () use($app) {
return $app['twig']->render('cars.html.twig', array('cars' => Car::getAll()));
});
// Page: car newly added.
$app->post('/car_added', function () use($app) {
$car = new Car($_POST['model'], $_POST['price'], $_POST['miles'], $_POST['image']);
$car->save();
return $app['twig']->render('car_added.html.twig', array('newcar' => $car));
});
// Page: Delete cars
$app->post('/delete_cars', function () use($app) {
Car::deleteAll();
return $app['twig']->render('delete_cars.html.twig');
});
// Page: results display.
$app->get('/results', function () use($app) {
// $cars = array(Car::getAll());
$cars_we_want = array();
foreach ($_SESSION['list_of_cars'] as $car) {
if ($car->getPrice() < $_GET["price"] && $car->getMiles() < $_GET["miles"]) {
array_push($cars_we_want, $car);
}
}
// Set the array "cars" as equal to "$cars_we_want", pass it to results page
return $app['twig']->render('results.html.twig', array('cars' => $cars_we_want));
});
return $app;