本文整理汇总了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);