📜  laravel 路由可选参数 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:36.777000             🧑  作者: Mango

代码示例6
// You can make a parameter optional by placing a '?' after the parameter name.
// Make sure to give the route's corresponding variable a default value:
Route::get('user/{name?}', function ($name = null) {
    return $name;
});

Route::get('user/{name?}', function ($name = 'John') {
    return $name;
});