Isset 检查 Array - Blade Laravel 5.8
Isset check on Array - Blade Laravel 5.8
如果我这样做
{{ dd($alert) }}
我得到了
array:7 [▼
"created_at" => "2019-12-30 17:31:55.728307+00:00"
"fail_cnt" => 123
"updated_at" => "2019-12-30 17:31:55.728307+00:00"
]
提示:它是一个数组,不是一个对象。
我正在尝试对数组使用 isset 检查
<input required type="number" name="slaac" class="form-control form-control-sm" placeholder="1000" value="{{ $alert['slaac_threshold'] or '' }}">
我一直在
我做错了什么?
只需使用空合并运算符 ??
即可:
{{ $alert['slaac_threshold'] ?? '' }}
Blade 中的 OR
运算符已在 Laravel 5.7 中删除,并且从未完全正常工作。
"The Blade "or" operator has been removed in favor of PHP's built-in ??
"null coalesce" operator, which has the same purpose and functionality" - Laravel 5.7 Docs - Upgrade Guide - Blade
如果我这样做
{{ dd($alert) }}
我得到了
array:7 [▼
"created_at" => "2019-12-30 17:31:55.728307+00:00"
"fail_cnt" => 123
"updated_at" => "2019-12-30 17:31:55.728307+00:00"
]
提示:它是一个数组,不是一个对象。
我正在尝试对数组使用 isset 检查
<input required type="number" name="slaac" class="form-control form-control-sm" placeholder="1000" value="{{ $alert['slaac_threshold'] or '' }}">
我一直在
我做错了什么?
只需使用空合并运算符 ??
即可:
{{ $alert['slaac_threshold'] ?? '' }}
Blade 中的 OR
运算符已在 Laravel 5.7 中删除,并且从未完全正常工作。
"The Blade "or" operator has been removed in favor of PHP's built-in
??
"null coalesce" operator, which has the same purpose and functionality" - Laravel 5.7 Docs - Upgrade Guide - Blade