get() public static method

注册GET路由
public static get ( string $rule, string $route = '', array $option = [], array $pattern = [] ) : void
$rule string 路由规则
$route string 路由地址
$option array 路由参数
$pattern array 变量规则
return void
Beispiel #1
0
 public function testBind()
 {
     $request = Request::instance();
     Route::bind('index/blog');
     Route::get('index/blog/:id', 'index/blog/read');
     $result = Route::check($request, '10');
     $this->assertEquals(['index', 'blog', 'read'], $result['module']);
     Route::bind('\\app\\index\\controller', 'namespace');
     $this->assertEquals(['type' => 'method', 'method' => ['\\app\\index\\controller\\blog', 'read']], Route::check($request, 'blog/read'));
     Route::bind('\\app\\index\\controller\\blog', 'class');
     $this->assertEquals(['type' => 'method', 'method' => ['\\app\\index\\controller\\blog', 'read']], Route::check($request, 'read'));
 }
Beispiel #2
0
 public function testRoot()
 {
     Config::set('url_domain_deploy', false);
     Config::set('url_common_param', false);
     Url::root('/index.php');
     Route::get('blog/:id', 'index/blog/read');
     Config::set('url_html_suffix', 'shtml');
     $this->assertEquals('/index.php/blog/10/name/thinkphp.shtml', Url::build('index/blog/read?id=10&name=thinkphp'));
 }
Beispiel #3
0
<?php

function a2($a, $b)
{
    return $a + $b;
}
\think\Route::get('getsession/:time', function ($time) {
    //获取session ssid
    $arr = array();
    $ssid = md5(mt_rand(1, 999999) . time() . mt_rand(1, 999999));
    $arr['ssid'] = $ssid;
    $arr['session_die_time'] = time() + $time;
    S("ssid_" . $ssid, $arr, $time);
    return $arr;
});
\think\Hook::add('action_begin', function () {
    //签名验证
    return;
    $getArr = I('get.');
    if (!$getArr) {
        return;
    }
    $sign = isset($getArr['sign']) ? $getArr['sign'] : system_error("not_fonud_sign");
    unset($getArr['sign']);
    ksort($getArr);
    $signstr = "";
    foreach ($getArr as $k => $v) {
        $signstr .= $k . "=" . urlencode($v) . "&";
    }
    $signstr = rtrim($signstr, "&");
    if (md5($signstr) != $sign) {
Beispiel #4
0
 public function testBind()
 {
     Route::bind('module', 'index/blog');
     $this->assertEquals(['type' => 'module', 'module' => ['index', 'blog', 'read']], Route::parseUrl('read/10'));
     Route::get('index/blog/:id', 'index/blog/read');
     $this->assertEquals(['type' => 'module', 'module' => ['index', 'blog', 'read']], Route::check('10'));
     Route::bind('namespace', '\\app\\index\\controller');
     $this->assertEquals(['type' => 'method', 'method' => ['\\app\\index\\controller\\blog', 'read'], 'params' => []], Route::check('blog/read'));
     Route::bind('class', '\\app\\index\\controller\\blog');
     $this->assertEquals(['type' => 'method', 'method' => ['\\app\\index\\controller\\blog', 'read'], 'params' => []], Route::check('read'));
 }
Beispiel #5
0
 public function testBuildAnchor()
 {
     Route::get('blog/:id', 'index/blog');
     Config::set('url_html_suffix', 'shtml');
     $this->assertEquals('/blog/10.shtml#detail', Url::build('/blog/10#detail'));
 }