有没有一种方法可以使Visual Studio Code识别PHP文件中的HTML语法 [英] Is there a way to make Visual Studio Code recognize HTML syntax in PHP files

查看:42
本文介绍了有没有一种方法可以使Visual Studio Code识别PHP文件中的HTML语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Mac上使用Visual Studio Code来处理WordPress应用程序.

I am using Visual Studio Code on a Mac to work on WordPress applications.

有没有一种方法可以使Visual Studio Code识别HTML并在PHP文件中使用它的功能(主要是自动完成功能)?

Is there a way to make Visual Studio Code recognize HTML and use it's features (mainly autocompletion) inside PHP files?

我之前一直在搜索此答案,但只是被告知转到"Visual Studio代码设置": File>>首选项>>用户设置

I've searched for this answer before but just get told to Go to Visual Studio Code Settings: File >> Preferences >> User Settings

// Place your settings in this file to overwrite the default settings
{                
// Configure file associations to languages (e.g. "*.extension": "html"). These have precedence over the default associations of the languages installed.
     "files.associations": {"*.php": "html"}     
 }

但是这样做会使您失去所有PHP支持和自动补全功能.

我希望微软能够意识到,PHP开发人员在创建应用程序/网站时通常会同时使用PHP和HTML.如果可能的话,我想使用VS Code代替华丽但昂贵的PHP风暴.

I wish Microsoft would realize that PHP developers commonly use PHP and HTML together when creating applications/websites. I would love to use VS Code instead of the magnificent but expensive PHP storm if possible.

推荐答案

据我所知,确实如此.看一下我在VS Code中创建的这个 php 文件(无扩展名),文件中带有HTML,并突出显示了两种语言的语法.

As far as I can tell, it does. Take a look at this php file I have created in VS Code (no extensions), with HTML inside the file with syntax highlighting for both languages.

在屏幕的右下角有一个按钮(应该说PHP这个词),您可以将语法高亮和自动完成功能切换为另一种语言,尽管这确实会暂时关闭PHP语法,但它将允许您可以更轻松地用HTML编写代码.

There is a button (It should say the word PHP) in the bottom right corner of the screen that allows you to switch the syntax highlighting and autocompletion to another language, and while this does temporarily turn off PHP syntax, it will allow you to code in HTML a lot easier.

这篇关于有没有一种方法可以使Visual Studio Code识别PHP文件中的HTML语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆