Home>Article>Backend Development> How to solve the problem of garbled Chinese characters output by PHP?
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.
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 visitPHP 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!