Home > Article > Backend Development > How to solve the problem that Chinese characters are not displayed in php
Solution: 1. Use "header("Content-type:text/html;charset:utf-8")" to set the encoding format of the page to "utf-8"; 2. Modify "php The content of "default_charset" in the .ini" file is "UTF-8".
The operating environment of this article: Windows 10 system, PHP version 7.1, Dell G3 computer.
1. Create a new php file, name it test.php, and use the header() method to set the encoding format of the page to utf-8.
Examples are as follows:
2. Find the php.ini file, usually under the php directory file. Open the file, hold down ctrl F to find the configuration item that needs to be modified, and then remove the previous comment, usually a semicolon (i.e.;). Then modify the required values and save the file. Just restart PHP and the server apache or nginx.
Open the php.ini file, find;default_charset = "iso-8859-1", change it to: default_charset = "UTF-8", remove the semicolon in front (remove the comment), and change the character set to UTF -8, restart the apache service, refresh the page, and the Chinese display will be normal.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to solve the problem that Chinese characters are not displayed in php. For more information, please follow other related articles on the PHP Chinese website!