Home > Backend Development > PHP Problem > Wamp runs PHP and Chinese characters are garbled

Wamp runs PHP and Chinese characters are garbled

王林
Release: 2023-02-23 22:36:02
Original
4490 people have browsed it

Wamp runs PHP and Chinese characters are garbled

How to solve the problem of Chinese garbled characters when running php files in wamp?

Method 1:

Add the following code to the header of the php file:

header('Content-Type:text.html;charset=UTF-8');
Copy after login

Method 2:

When saving the php file, it needs to be stored in UTF-8 BOM format. However, this method has a disadvantage. It can be tested locally, but garbled characters will appear when transmitted to the website.

Wamp runs PHP and Chinese characters are garbled

Method 3:

Change the default character set of the file to UTF-8. Perfect problem solving.
Find \wamp64\bin\php\php5.6.31\php.ini

Search for the relevant code and modify it as follows. Pay attention to the PHP version you are using. Different versions of php.ini are in different In the folder

; PHP's default character set is set to UTF-8.
; http://php.net/default-charset
default_charset = "UTF-8"
Copy after login

The above content is for reference only!

Recommended video tutorial: PHP video tutorial

The above is the detailed content of Wamp runs PHP and Chinese characters are garbled. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template