Copy/paste from w3chools gives PHP error. Parse error: syntax error, unexpected

Copy/paste from w3chools gives PHP error. Parse error: syntax error, unexpected

我正在使用 WAMP 并尝试了不同的浏览器。这个例子是从 w3schools 复制粘贴的。但我得到:

解析错误:语法错误,第 10 行 C:\wamp64\www\tuto\otro.php 中出现意外的“ ” (T_STRING)。

第 10 行是:$GLOBALS['y'] = $GLOBALS['x'] + $GLOBAL['y'];

我真的不明白为什么它在 w3schools 编辑器上有效,但在我的浏览器上却无效。其他基本代码工作正常,WAMP 工作正常。我有PHP版本5.6.19,教程也是PHP5w3schools code

<!DOCTYPE html>
<html>
    <body>

        <?php
            $x = 5;
            $y = 10;

            function myTest() {
                $GLOBALS['y'] = $GLOBALS['x'] + $GLOBAL['y'];
            } 

            myTest();
            echo $y; // outputs 15
        ?> 

    </body>
</html>

语法 $GLOBAL['y']; 中缺少 'S'。所以更新的脚本是,

 $x = 5;
        $y = 10;

        function myTest() {
            $GLOBALS['y'] = $GLOBALS['x'] + $GLOBALS['y'];
        } 

        myTest();
        echo $y; // outputs 15