Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel-未定义索引:Id_Php_Laravel - Fatal编程技术网

Php Laravel-未定义索引:Id

Php Laravel-未定义索引:Id,php,laravel,Php,Laravel,在我的刀片服务器中,我回显了一个发货ID。如果我使用“dd()”,它会正确转储该号码。当我尝试回显它时,我得到一个错误:“Undefined index:Id”我很困惑,如果dd()有效,为什么会抛出错误 产出:1 234 echo $shipping['Id']; 输出:错误:未定义索引:Id您正在foreach中使用代码。当dd($shipping['Id'])是第一个循环,第一个$shipping包含'Id',当使用echo$shipping['Id']时,会出现错误,因为$shippi

在我的刀片服务器中,我回显了一个发货ID。如果我使用“dd()”,它会正确转储该号码。当我尝试回显它时,我得到一个错误:“Undefined index:Id”我很困惑,如果dd()有效,为什么会抛出错误

产出:1 234

echo $shipping['Id'];

输出:错误:未定义索引:Id

您正在
foreach
中使用代码。当
dd($shipping['Id'])是第一个循环,第一个
$shipping
包含
'Id'
,当使用echo$shipping['Id']时,会出现错误,因为
$shipping
中的一个不包含
Id
。用于固定刀片使用

@if(!empty($shipping['Id']))
    {{$shipping['Id']}}
@endif


var_dump($shipping)你在使用loop吗?@Abracadver@Davit是的,我有一个foreach,我想这可能是问题所在。。。
@if(!empty($shipping['Id']))
    {{$shipping['Id']}}
@endif
echo $shipping['Id'] ?? '';