Home >Backend Development >PHP Problem >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!