Visual Studio Code 中 PHP/HTML 的格式代码命令

2024-05-10php开发问题
7

本文介绍了Visual Studio Code 中 PHP/HTML 的格式代码命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

是否可以让 Visual Studio Code 在 Windows Visual Studio Code 版本 0.7.1 上格式化混合的 HTML 和 PHP 代码?

Is it possible to get Visual Studio Code to format mixed HTML and PHP code on Windows Visual Studio Code version 0.7.1?

推荐答案

更新2021-07-21

距离我第一次写这个答案已经有五年多了.我最初链接的扩展被放弃了,Visual Studio Code 的内在 PHP 支持没有改进,这令人失望.我所知道的唯一一个不错的扩展是 PHP Intelephense,它使用免费增值模式:基本功能是免费的,在撰写本文时,终身许可为 12 美元.

Update 2021-07-21

It's been more than half a decade since I first wrote this answer. The extensions to which I originally linked are abandoned, and Visual Studio Code's intrinsic PHP support hasn't improved, which is disappointing. The only decent extension still standing of which I'm aware is PHP Intelephense, which uses a freemium model: basic features are free, and a lifetime license is $12 USD as of writing.

免费版本的 Intelephense 支持使用常用快捷键(在 Windows 和 Linux 上为 Alt + Shift + FF 在 macOS 上).Visual Studio Code 仍然缺乏对 PHP 代码格式化的内置支持,如果您在未安装适当扩展的情况下尝试格式化 PHP,则会将您引导至扩展市场.

The free version of Intelephense supports code formatting with the usual shortcuts (Alt + Shift + F on Windows and Linux, F on macOS). Visual Studio Code continues to lack built-in support for PHP code formatting and will direct you to the extension marketplace if you attempt to format PHP without an appropriate extension installed.

Visual Studio Code 具有非常棒的 PHP 支持.extensions 涵盖了它所缺少的内容.快速搜索发现至少三个(1, 2 和 3) 声称支持 PHP 格式.

Visual Studio Code has pretty awesome PHP support. What it lacks is covered by extensions. A quick search reveals at least three (1, 2, and 3) that claim to support PHP formatting.

他们似乎在 Windows/Linux 上使用标准快捷键 Alt + Shift + F,在 Mac 上使用不同的快捷键.如果您使用的是 Mac,请尝试 F.

They mostly seem to use the standard shortcut of Alt + Shift + F on Windows/Linux, with varying shortcuts on Mac. If you're on Mac, give F a try.

这篇关于Visual Studio Code 中 PHP/HTML 的格式代码命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

PHP实现DeepL翻译API调用
DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以...
2025-08-20 php开发问题
168

PHP通过phpspreadsheet导入Excel日期数据处理方法
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的...
2024-10-23 php开发问题
287

mediatemple - 无法使用 codeigniter 发送电子邮件
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)...
2024-08-23 php开发问题
11

Laravel Gmail 配置错误
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)...
2024-08-23 php开发问题
16

将 PHPMailer 用于 SMTP 的问题
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)...
2024-08-23 php开发问题
4

关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)...
2024-08-23 php开发问题
17