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

Wamp runs PHP and Chinese characters are garbled

王林
王林Original
2019-09-11 17:53:214451browse

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');

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"

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!

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