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

What to do if php runs with garbled characters

藏色散人
Release: 2023-02-25 20:54:02
Original
4807 people have browsed it

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")
Copy after login

Add to the static page

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

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

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

Static page addition

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

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!

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