为什么这个 php 数组函数给我一个错误

Why does this php array function gives me an error

if (array_key_exists('icon_path', $changedAttributes)) {
    $iconFile = $changedAttributes["icon_path"];
}

为什么 $iconFile = $changedAttributes["icon_path"]; 行在 php 7.2 中出现以下错误? 即使我将其更改为单引号 ['icon_path'] 也没有解决问题。

syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)

但是在php7.4中完全没有问题。

我用这个版本检查器检查了我的代码 https://www.piliapp.com/php-syntax-check/ 7.2 给我这个错误,但 7.4 工作正常。

这是一个缩进问题。我的代码有以下 JavaScript 代码。

public function reloadPageOnEdit()
{
    return <<<JSCRIPT
        <script>
            function openWindowReload(link) {
                var href = link.href;
                
                document.location.reload(true);
                window.open(href,'_self');
            }
        </script>
        JSCRIPT;
}

我把它完全缩进了左边。它解决了这个问题。即使在 7.4 中没有问题,但在 7.2 中。 我很困惑,因为代码在其他地方失败了。

    public function reloadPageOnEdit()
    {
        return <<<JSCRIPT
<script>
    function openWindowReload(link) {
        var href = link.href;
        
        document.location.reload(true);
        window.open(href,'_self');
    }
</script>
JSCRIPT;
    }