Solution for bat to execute php Chinese garbled code: 1. Use the Notepad that comes with the Windows operating system platform to open the script file; 2. Click the menu [File] - [Save As] operation; 3. Select ANSI encoding Save; 4. Declare the code page change in the original bat script file.
The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.
What should I do if bat executes Chinese garbled code in php?
bat batch script solution to Chinese garbled characters
Problem description
bat batch script is as follows
@echo off echo hello,world. echo 你好,中国 pause
When CMD executes the script, Chinese garbled characters
Problem analysis
- Garbled characters are all related to character encoding.
- The computer can only process numbers. If it encounters text, it must be converted into numbers before it can be processed. This is where character encoding (character set) appears. If a certain character encoding is used for encoding, the same character encoding must be used for decoding. If different character encodings are used, garbled characters will appear.
Problem Solving
1. Convert the encoding method of the script file
By default, in the bat script file, if the Chinese is not ANSI encoding, it will appear Garbled characters. Therefore, you can use the Notepad that comes with the Windows operating system platform to open the script file, click the menu [File] - [Save As], and select ANSI encoding to save.
After converting the encoding and running it again, the Chinese garbled problem is solved.
2. Change the code page
Declare the code page change in the original bat script file
chcp 65001
Run again, the Chinese garbled problem is solved.
Extensionchcp Command
Changes the active console code page.
Commonly used Code page mapping
Code page | Mapped character set |
---|---|
936 | GB2312 |
20127 | US-ASCII |
65001 | UTF-8 |
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What to do if bat executes php Chinese garbled code. For more information, please follow other related articles on the PHP Chinese website!

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver Mac version
Visual web development tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Mac version
God-level code editing software (SublimeText3)