public function test()
{
$test = request()->input('test','this is test !!!');
dd($test);
}
-
請求時,沒有
test
參數字段時,$test='this is test !!!'
-
請求時,test參數為空時,
$test
為空,而不是this is test !!!
感覺 input() 方法第二個參數,沒什么用,可以用 ??
替代
這樣沒有傳test
參數字段或test
參數為空,都會取到默認值
public function test()
{
$test = request()->input('test') ?? 'this is test !!!';
dd($test);
}