diff --git a/routing.md b/routing.md index 1a050fbd61..71a8393507 100644 --- a/routing.md +++ b/routing.md @@ -197,11 +197,11 @@ If your route has dependencies that you would like the Laravel service container Occasionally you may need to specify a route parameter that may not always be present in the URI. You may do so by placing a `?` mark after the parameter name. Make sure to give the route's corresponding variable a default value: - Route::get('/user/{name?}', function (string $name = null) { + Route::get('/user/{name?}', function (?string $name = null) { return $name; }); - Route::get('/user/{name?}', function (string $name = 'John') { + Route::get('/user/{name?}', function (?string $name = 'John') { return $name; });