thinkphp路由

一、普通模式

'url_route_on'  =>  false,

二、混合模式

'url_route_on'  =>  true,
'url_route_must'=>  false,

三、注册路由规则

配置文件application/route.php进行注册:
use think\Route;
// 注册路由到index模块的News控制器的read操作
Route::rule('new/:id','index/News/read');

return [
'__pattern__' => [
'name' => '\w+',
],
'[hello]' => [
':id' => ['index/hello', ['method' => 'get'], ['id' => '\d+']],
':name' => ['index/hello', ['method' => 'post']],
],

];

  四、URL生成

Url::build('index/blog/read','id=5&name=thinkphp');
Url::build('index/blog/read',['id'=>5,'name'=>'thinkphp']);

  



 

 

posted on 2018-01-02 15:53  张扬个性,敢为天下先  阅读(201)  评论(0编辑  收藏  举报