本文整理匯總了PHP中DefaultController::run方法的典型用法代碼示例。如果您正苦於以下問題:PHP DefaultController::run方法的具體用法?PHP DefaultController::run怎麽用?PHP DefaultController::run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DefaultController
的用法示例。
在下文中一共展示了DefaultController::run方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: isset
<?php
/**
* Copyright (c) 2014 Keith Casey
*
* This code is designed to accompany the lynda.com video course "Design Patterns in PHP"
* by Keith Casey. If you've received this code without seeing the videos, go watch the
* videos. It will make way more sense and be more useful in general.
*/
include_once 'controllers/default_controller.php';
include_once 'controllers/number_controller.php';
include_once 'models/number_model.php';
$action = isset($_GET['a']) ? $_GET['a'] : 'index';
$module = isset($_GET['m']) ? $_GET['m'] : '';
$id = isset($_GET['id']) ? $_GET['id'] : '';
switch ($module) {
case 'number':
$controller = new NumberController();
break;
default:
$controller = new DefaultController();
}
$controller->run($action, $id);
示例2: function
<?php
/**
* Copyright (c) 2014 Keith Casey.
*
* This code is designed to accompany the lynda.com video course "Design Patterns in PHP"
* by Keith Casey. If you've received this code without seeing the videos, go watch the
* videos. It will make way more sense and be more useful in general.
*/
require 'vendor/autoload.php';
include_once 'controllers/default_controller.php';
include_once 'controllers/number_controller.php';
include_once 'models/number_model.php';
$app = new \Slim\Slim();
$app->get('/', function () {
include 'views/default.php';
});
$app->get('/:module(/:number)', function ($module, $number = 1) {
switch ($module) {
case 'number':
$controller = new NumberController();
break;
default:
$controller = new DefaultController();
}
$action = 'view';
$controller->run($action, $number);
});
$app->run();
示例3: isset
<?php
/**
* Copyright (c) 2014 Keith Casey
*
* This code is designed to accompany the lynda.com video course "Design Patterns in PHP"
* by Keith Casey. If you've received this code without seeing the videos, go watch the
* videos. It will make way more sense and be more useful in general.
*/
include_once 'controllers/default_controller.php';
include_once 'controllers/greeting_controller.php';
include_once 'models/greeting.php';
$action = isset($_GET['a']) ? $_GET['a'] : 'index';
$module = isset($_GET['m']) ? $_GET['m'] : '';
switch ($module) {
case 'greeting':
$controller = new GreetingController();
break;
default:
$controller = new DefaultController();
}
$controller->run($action);