嗨,如何在代码点火器 php 上添加用于路由的可选参数
$route['api/v1/(:any)'] = "$1/index";
$route['api/v1/(:any)/(:any)'] = "$1/index/$2";
网址,例如:
app.domain.com/api/v1/users 呼叫$users->index()
app.domain.com/api/v1/users/1 呼叫$users->index(1)
我需要tge路线是动态的$route['api/v1/(:any)']
我需要"用户"可以是动态的。我已经创建了一个路线,它对我有用,你能检查一下这是否是最好的方法吗?
$route['api/v1/(:any)/([a-z 0-9~%.:@_'-]+)/(:any)'] = "$1/index/$2/$3";
$route['api/v1/(:any)/(:num)'] = "$1/index/$2";
$route['api/v1/(:any)'] = "$1/index";
谢谢