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


PHP Car::worthBuying方法代码示例

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


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

示例1: array

$app['debug'] = true;
$app = new Silex\Application();
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
session_start();
if (empty($_SESSION['list_of_cars'])) {
    $porsche = new Car("2014 Porsche 911", 114991, 7864, "images/porsche.jpg");
    $ford = new Car("2011 Ford F450", 55995, 14241, "images/ford.jpg");
    $lexus = new Car("2013 Lexus RX 350", 44700, 20000, "images/lexus.jpg");
    $mercedes = new Car("Mercedes Benz CLS550", 39900, 37979, "images/mercedes.jpg");
    $cars = array($porsche, $ford, $lexus, $mercedes);
    $_SESSION['list_of_cars'] = $cars;
}
$app->get("/", function () use($app) {
    $cars = $_SESSION['list_of_cars'];
    return $app['twig']->render('cars.html.twig', array('cars' => $cars));
});
$app->post("/create_cars", function () use($app) {
    $car = new Car($_POST['make'], $_POST['miles'], $_POST['price'], $_POST['image']);
    $car->save();
    return $app['twig']->render('create_cars.html.twig', array('car' => $car));
});
$app->post("/search_car", function () use($app) {
    $cars_matching_search = array();
    foreach ($_SESSION['list_of_cars'] as $car) {
        if ($car->worthBuying($_POST["price"], $_POST["miles"])) {
            array_push($cars_matching_search, $car);
        }
    }
    return $app['twig']->render('search_car.html.twig', array('cars_matching_search' => $cars_matching_search));
});
return $app;
开发者ID:boloround,项目名称:project,代码行数:31,代码来源:app.php

示例2: array

    $_SESSION['cars_list'] = array();
}
$app = new Silex\Application();
// $app['debug'] = true;
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get("/", function () use($app) {
    return $app['twig']->render('car_form.html.twig');
});
$app->post("/show", function () use($app) {
    $car = new Car($_POST['model'], $_POST['price'], $_POST['image'], $_POST['miles']);
    $car->save();
    return $app['twig']->render('car_dealership.html.twig', array('cars' => Car::getAll()));
});
$app->get("/list", function () use($app) {
    return $app['twig']->render('car_dealership.html.twig', array('cars' => Car::getAll()));
});
$app->get("car_search", function () use($app) {
    $cars = Car::getAll();
    $cars_matching_search = array();
    foreach ($cars as $car) {
        if ($car->worthBuying($_GET["price"]) && $car->maxMileage($_GET["mileage"])) {
            array_push($cars_matching_search, $car);
        }
    }
    return $app['twig']->render('car_search.html.twig', array('cars' => $cars_matching_search));
});
$app->post("/clear", function () use($app) {
    Car::reset();
    return $app['twig']->render('car_dealership.html.twig', array('cars' => Car::getAll()));
});
return $app;
开发者ID:adamrr724,项目名称:Car-PHP,代码行数:31,代码来源:app.php


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