I just learned the laravel framework and found that the order of routes will affect the content played. Why?
normal code:
Route::get("posts",function (){
return "index";
});
Route::get("posts/create",function (){
return "create";
});
Route::get("posts/{post}",function (){
return "post";
});
exception code:
Route::get("posts",function (){
return "index";
});
Route::get("posts/{post}",function (){
return "post";
});
Route::get("posts/create",function (){
return "create";
});
there is no difference between the two pieces of code, except that the routing order is different. When accessing the post/create
route, the exception code returns the contents of posts/ {post}
.