use think\Route;
//静态路由
Route::rule('/', 'index/index/index');
Route::rule('test', 'index/index/test');
//带参数
Route::rule('coure/:id', 'index/index/coure'); //可选参数路由
Route::rule('coure/:id/[:name]', 'index/index/coure'); //完全匹配路由
Route::rule('test1$', 'index/index/test1'); //额外参数
Route::rule('test2$', 'index/index/test2?id=1'); //测试
Route::rule('view', 'index/index/view');
Route::rule('views', 'admin/index/view');
//-----
namespace app\index\controller; class Index
{
public function index()
{ return "index";
} //demo
public function test()
{
return "我是用户自己";
} public function coure()
{
echo input('id') . '' . input('name');
} public function test1()
{
return "完全匹配路由";
} public function test2()
{
dump(input());
return "额外参数test2";
} public function view()
{
return view();
}
}