Home >Backend Development >PHP Problem >How to debug PHP garbled code using VSCODE

How to debug PHP garbled code using VSCODE

藏色散人
藏色散人Original
2023-01-19 09:36:312150browse

VSCODE debugging PHP garbled solution: 1. Find and open the "tasks.json" file; 2. Add ""-finput-charset=GBK" after "args" in the "tasks.json" file " can solve the problem of garbled characters.

How to debug PHP garbled code using VSCODE

The operating environment of this tutorial: Windows 10 system, PHP version 8.1, DELL G3 computer

What should I do if VSCODE debugs PHP garbled code?

vsCode outputs Chinese garbled characters in debugging mode

Preface

I recently used vsCode, and after changing the character set, it ran normally and debugged Chinese garbled characters. Record it. My own solution:)

1. Reasons for triggering this problem

Since the default encoding format of vsCode is UTF-8, the default encoding format of cmd (country area) is GBK,

vsCode terminal will call cmd, and the encoding formats of the two are different, which will lead to garbled characters.

The solution is to set the default encoding of vsCode to GBK, but the generated exe file is still in accordance with UTF-8 output,

So debugging will be garbled

2. Solution

The solution found on the Internet is: in tasks,json Add

 // "-fexec-charset=GBK", 
 "-finput-charset=GBK"  // 处理mingw中文编码问题

after the "args" of the file, where -fexec-charset specifies the encoding format of the input file

-finput-charset specifies the encoding format to generate the executable,

here I only need to change the encoding of the executable file to GBK

The input file encoding itself has been changed to GBK by me, so there is no need to change it here.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to debug PHP garbled code using VSCODE. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn