Visual Studio code php color 未显示在 html 文件中



我正在尝试在Visual Studio code HTML文件中使用PHP代码,但无法获得颜色突出显示。我已经安装了PHP智能感知,但仍然相同

<div class="htmlcolor">
<?php
echo "php color not working in html file";
?>
</div>

尝试将文件从your-file.html重命名为your-file.php,以便为htmlphp启用 PHP 代码突出显示

通常这与与另一个格式化插件冲突的 VS 代码插件有关。 我已经禁用了所有格式化插件并仅重新启用Prettier,这确实起到了作用。

在 VS-Code 中,安装扩展PHP Extension Pack。这将帮助您突出显示颜色,自动完成,建议等:)是的,正如 dstrants 所提到的,您应该将代码保存在 php 文件中。

最新更新