![How to add utf8 in php](https://img.php.cn/upload/article/000/000/029/5d8316f103220419.jpg)
PHP sets the encoding of the file, the statement used:
header("Content-Type: text/ html;charset=Specify encoding"); (Recommended learning: PHP programming from entry to proficiency)
![1568872110122236.png How to add utf8 in php](https://img.php.cn/upload/image/772/947/863/1568872110122236.png)
## Why do we need to set the character set encoding of the file?
![1568872122878049.png How to add utf8 in php](https://img.php.cn/upload/image/930/671/513/1568872122878049.png)
As shown below, it is because the browser cannot correctly identify the encoding of the file, resulting in abnormal display
![1568872132674327.png How to add utf8 in php](https://img.php.cn/upload/image/533/435/358/1568872132674327.png)
Example Demo, specify the encoding of the file
![1568872143923626.png How to add utf8 in php](https://img.php.cn/upload/image/302/227/704/1568872143923626.png)
Save the file and view the correctly encoded content output in the browser,
![1568872153870786.png How to add utf8 in php](https://img.php.cn/upload/image/577/771/506/1568872153870786.png)
The above is the detailed content of How to add utf8 in 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