Error : Getting "Undefined array key" whule running my application in open cart

Error : Getting "Undefined array key" whule running my application in open cart

我的代码:

 $data['components'][] = array(
                        'id_component' => $component['id_component'],
                        'id_layout' => $component['id_layout'],
                        'component_type' => $this->model_webservice_webservice->getComponentTypeByID($component['id_component_type']),
                        'component_heading' => @$component['component_heading'],
                        'data' => $component_data,
                        'product_data' => $products
                    );

错误行: 'component_heading' => @$component['component_heading'],

错误未定义数组键 C:\xampp\htdocs***[=中的“component_heading” 26=].php 第 1870 行警告:

避免使用错误抑制运算符(它的行为 has changed 自 PHP8。

当没有这样的键时,您可以使用以下语法之一:

'component_heading' => $component['component_heading'] ?? null, // null coalesce operator
'component_heading' => isset($component['component_heading']) ? $component['component_heading'] : null,
'component_heading' => array_key_exists('component_heading', $component) ? $component['component_heading'] : null,