tp5 路由参数获取问题

浏览:10500 发布日期:2017/10/19 分类:ThinkPHP5专区 关键字: tp5 路由
Route::rule('new/:id','index/News/read');
手册中说 http://serverName/new/5自动路由到 http://serverName/index/news/read/id/5
但是 通过get方式获取id获取不到 ,为啥直接是参数
public function read($id) {
dump($id);
}
这样能获取....

还有 route.php中默认的这个hello怎么用,参数写默认值吗?
return [
'__pattern__' => [
'name' => '\w+',
],
'[hello]' => [
':id' => ['index/hello', ['method' => 'get'], ['id' => '\d+']],
':name' => ['index/hello', ['method' => 'post']],
],
];
这样用????
public function hello($id=0,$name='') {
dump($id);
dump($name);
}
最佳答案
评论( 相关
后面还有条评论,点击查看>>