【发布时间】:2013-09-27 09:21:08
【问题描述】:
-
我的路线.php
Route::get('course/{id}', 'CourseController@show'); Route::get('course/{id}/{comment_type}', 'CourseController@show'); Route::get('course/search/{key_word}', 'CourseController@search'); -
我的 CourseController.php 有这些方法
public function show($id,$comment_type=1) { //do something } public function search($key_word) { //do something } -
我想进入
search方法。但每次我调用course/search/{key_word} //search method in CourseCOntroller进入
course/{id}/{comment_type} //show method in CourseCOntroller -
我调试源代码。而且我发现
UrlMatcher有一个matchCollection函数,我找到了原因,laravel生成了一个错误的Regular Expression当我调用course/search/{key_word}时,它会生成这样的正则表达式?#^/course/(?P<id>[^/]++)/(?P<comment_type>[^/]++)$#s 不知道这个正则表达式是怎么产生的。
我该如何解决这个问题,当我调用
course/search/{key_word}时它会调用search方法。
【问题讨论】:
标签: php regex laravel laravel-4