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


PHP Car::getMiles方法代码示例

本文整理汇总了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;
开发者ID:jeffaustin81,项目名称:car_application,代码行数:31,代码来源:app.php

示例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;
开发者ID:slmaturen,项目名称:Car_Dealership_With_Twig,代码行数:31,代码来源:app.php


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