Home>Article>Backend Development> How to solve the problem of garbled Chinese characters output by PHP?

How to solve the problem of garbled Chinese characters output by PHP?

青灯夜游
青灯夜游 Original
2019-10-12 15:31:22 4054browse

When writing code in PHP, sometimes you may find that the Chinese output has garbled characters. So, how should we solve this kind of garbled PHP output? Let me introduce to you the solution below.

How to solve the problem of garbled Chinese characters output by PHP?

The problem with php outputting garbled Chinese characters is nothing more than the following aspects;

1. HTML page encoding settings

1. Add this sentence

  

in the head tag. 2. Set the encoding to UTF-8 when saving the file.

2. PHP encoding settings

Based on method one, write

## at the very beginning of the PHP code, i.e. the first sentence #3. Mysql encoding settings

On the basis of the previous ones, you must also add database encoding before querying/modifying/adding your data.

Note that UTF8 is written here instead of UTF-8! ! !

Following the above method settings should be able to solve the problem of outputting Chinese garbled characters.

For more PHP related knowledge, please visit

PHP Chinese website!

The above is the detailed content of How to solve the problem of garbled Chinese characters output by PHP?. 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