web.php:
function sum($a, $b)
{
return $a + $b;
}
Route::get('/debug/{$a}/{$b}', function(Request $request , $a, $b) {
$sum = sum($a, $b);
return $sum;
});
我在visual studio代码"Symbol$请求已声明但未使用"中出错,在我的浏览器404中找不到,请帮助
只需使用以下代码:
Route::get('/debug/{a}/{b}', function($a, $b) {
return sum($a , $b);
});
或者简单地使用
Route::get('/debug/{a}/{b}', function($a, $b) {
return ($a + $b);
});
https://laravel.com/docs/8.x/routing#route-参数