Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我希望能够响应 Larvel 3 中包含未知数量段 N 的路线。例如
/segment_1/...segment_N-1/segment_N
路由应该将每个段的值发送到匿名函数。
我试过使用:
Route::get('/(:any)/(:all?)', function($segments){ //do something });
这接受所有路由,但仅将第一段发送到函数
Laravel 中是否有一种简单的方法来实现我所需要的?
不确定是否是最好的方法,但它对我有用。
Route::get('(:all)?', function() { $current = URI::current(); $segments = explode ('/', $current); foreach ($segments as $key => $value) { echo "URI Segment[" . $key . "]" . $value . "<br>"; } });