laravel_基础_路由及CSRF防护等
【说明:本笔记参照laravel学院帖子进行整理】
1.laravel基本的路由种类很多,常用的有any、get、post。
get
Route::get('/hello',function(){
return "Hello Laravel[GET]!";
});
post
Route::get('/testPost',function(){
$csrf_token = csrf_token();
$form = <<<FORM
<form action="/hello" method="POST">
<input type="hidden" name="_token" value="{$csrf_token}">
<input type="submit" value="Test"/>
</form>
FORM;
return $form;
});
Route::post('/hello',function(){
return "Hello Laravel[POST]!";
});