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