Home  >  Article  >  Backend Development  >  What to do if php runs with garbled characters

What to do if php runs with garbled characters

藏色散人
藏色散人Original
2019-10-09 09:43:494776browse

What to do if php runs with garbled characters

Solution to garbled code when running php:

Garbled code appears in PHP file output

php file The encoding itself and the encoding of the web page should match

a. If gb2312 encoding is used, then php should output the header:

header(“Content-Type: text/html; charset=gb2312")

Add to the static page

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

b. If using utf -8 encoding, then PHP should output the header:

header(“Content-Type: text/html; charset=utf-8")

Static page addition

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

For more PHP knowledge, please visit PHP Chinese website!

The above is the detailed content of What to do if php runs with garbled characters. 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