路由

laravel5.1路由在app/Http/routes.php中

而5.4在根目录的routes/web.php(一般用这个)


定义普通路由url/hello访问

Route::get('/hello',function(){return view});


有效路由有get post put patch delete options

Route::match(['get','post'],'/hello',function...);//match可以响应多种请求
Route::any("name",function...);//表示匹配所有请求

Route::get('hello'/{na},function($na)..);//必选参数
Route::get('hello'/{name?},function($na=chicai)..);//可选参数

url的名字和方法的名字是传值关系,命名可以不同

路由参数一定要用{}包括


首页 我的博客
粤ICP备17103704号