'; expected' PHP 中的 define() 函数中出现错误,即使我已经有了它



我正在尝试制作简单的PHP代码并遇到此错误。但是,当我运行测试时,一切都很好。

当我尝试使用define((进行恒定变量时,我会这样。

define('NAME', 'Yoshi');

出现的错误出现在分号旁边是:';预期的'。这是我的完整代码。

<?php
// index.php
    define('NAME', 'Yoshi');
    $age = 30;
?>
<!DOCTYPE html> 
<html>
    <head>
        <title> my PHP </title>
    </head>
    <body>
        <h1>Something here</h1>
        <div><?php echo NAME; ?></div>
        <div><?php echo $age; ?></div>
    </body>
</html>

php Intellisense 安装在VSCODE上时,您必须找到这些错误。

相关内容

最新更新