How to solve the problem that Chinese characters are not displayed in php

WBOY
Release: 2023-03-15 12:20:02
Original
3961 people have browsed it

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".

How to solve the problem that Chinese characters are not displayed in php

The operating environment of this article: Windows 10 system, PHP version 7.1, Dell G3 computer.

How to solve the problem that Chinese characters in php are not displayed

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:

How to solve the problem that Chinese characters are not displayed in php

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!