think\Route::bind PHP Method

bind() public static method

设置路由绑定
public static bind ( mixed $bind, string $type = 'module' ) : mixed
$bind mixed 绑定信息
$type string 绑定类型 默认为module 支持 namespace class
return mixed
    public static function bind($bind, $type = 'module')
    {
        self::$bind = ['type' => $type, $type => $bind];
    }

Usage Example

Example #1
0
 public function testDomain()
 {
     $_SERVER['HTTP_HOST'] = 'subdomain.thinkphp.cn';
     $_SERVER['REQUEST_URI'] = '';
     Route::domain('subdomain.thinkphp.cn', 'sub?abc=test&status=1');
     Route::checkDomain();
     $this->assertEquals('sub?abc=test&status=1', Route::domain('subdomain.thinkphp.cn'));
     $this->assertEquals('sub', Route::bind('module'));
     $this->assertEquals('test', $_GET['abc']);
     $this->assertEquals(1, $_GET['status']);
     Route::domain('subdomain.thinkphp.cn', function () {
         return ['type' => 'module', 'module' => 'sub2'];
     });
     Route::checkDomain();
     $this->assertEquals('sub2', Route::bind('module'));
     Route::domain('subdomain.thinkphp.cn', '\\app\\index\\controller');
     Route::checkDomain();
     $this->assertEquals('\\app\\index\\controller', Route::bind('namespace'));
     Route::domain('subdomain.thinkphp.cn', '@\\app\\index\\controller\\blog');
     Route::checkDomain();
     $this->assertEquals('\\app\\index\\controller\\blog', Route::bind('class'));
     Route::domain('subdomain.thinkphp.cn', '[sub3]');
     Route::checkDomain();
     $this->assertEquals('sub3', Route::bind('group'));
 }
All Usage Examples Of think\Route::bind