本文整理匯總了PHP中router::set方法的典型用法代碼示例。如果您正苦於以下問題:PHP router::set方法的具體用法?PHP router::set怎麽用?PHP router::set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類router
的用法示例。
在下文中一共展示了router::set方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$_SERVER['REQUEST_METHOD'] = 'GET';
router::route('/blog/:arg', function ($arg) {
echo 'Argument: ' . $arg;
}, 'GET', 'blog');
router::route('/blog/*', function () {
echo 'CatchAll';
});
router::route('/blog/arg', function () {
echo 'NoArg';
});
router::route('/test.php', function () {
echo 'test.php';
});
router::route('/proiecs/aed[]te\\*', function () {
echo '/proiecs/aed[]te\\*';
});
router::route('/proiecs/:ala/bala/:korhaz/:edit/:buha', function ($arg1, $arg2, $arg3) {
echo 'proiecs ' . $arg1 . $arg2 . $arg3;
}, 'GET', 'proiecs');
router::route('/proiecs/asfv', function () {
echo '/proiecs/asfv/';
});
router::route(' /infinity', function () {
echo 'infinity';
}, 'GET', 'infinity');
router::route('/infinity/ourubors/ternary', function () {
echo '/infinity/ourubors/ternary';
}, 'GET', 'infinity2');
router::set('BASE', 'framework');
}
示例2: loadTpl
public function loadTpl($tpl, $file = '', $time = 0)
{
mPHP::inc(MPHP_PATH . 'inc/functions.php');
//加載常用函數集
ob_start();
$arrData = $this->_include($tpl, $file);
ob_end_clean();
if (!mPHP::$debug) {
if ($this->is_merger) {
$arrData['html'] = $this->merger($arrData['html']);
}
if ($this->is_mini_html) {
$arrData['html'] = mini_html($arrData['html']);
}
}
//路由緩存邏輯
if ($time && !empty(mPHP::$CFG['router'])) {
$ctime = $_SERVER['REQUEST_TIME'];
$date = date('Y-m-d H:i:s');
$arrData['html'] .= "<!-- mPHP html cache {$date} -->";
$strDir = dirname($arrData['file']);
if (!is_dir($strDir)) {
mkdir($strDir, 0775, true);
}
file_put_contents($arrData['file'], $arrData['html']);
mPHP::header('Cache-Control', 'max-age=0');
mPHP::header('Last-Modified', date("D, d M Y H:i:s", $ctime));
$data = array('ctime' => $ctime, 'etime' => $ctime + $time, 'file' => $arrData['file']);
router::set($data);
}
echo $arrData['html'];
}