问题
How can i access this multi URL in laravel 4.2.
http://localhost/new/public/library/course/1/First%20Video
My code is
Route::get('library/course/{id}', function($id){
return View::make('course')->with('id',$id);
});
Route::get('library/course/{id}/{video}', function($id, $video){
$array = array('id' => '$id', 'video' => '$video');
return View::make('course')->withvideos($array);
});
回答1:
You are accessing the URL correctly, and it should reach your second route.
But you have a bug in your route:
// Your code
$array = array('id' => '$id', 'video' => '$video');
You shouldn't put single quotes around your variables -- it should be:
$array = array('id' => $id, 'video' => $video);
The single quotes force PHP not to resolve the two variables, so they are simply literal strings -- not what you want here.
Also, to pass the parameters to the view, you should adjust your code to use:
return view('course', $array);
来源:https://stackoverflow.com/questions/31840122/how-can-i-access-this-multi-url-in-laravel-4