Home >Backend Development >PHP Problem >How to set encoding format in php
php method to set the encoding format: first add [header("Content-Type: text/html; charset=utf-8")] in the php script; then set the encoding on the static page; finally ensure that all The encoding of the files is the same.
If you want to use gb2312 encoding, then PHP should output the header:
(Recommended tutorial: php graphic tutorial )
header(“Content-Type: text/html; charset=gb2312")
At the same time, add
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
to the static page and the encoding format of all files is ANSI. You can open it with Notepad, save it as and select the encoding as ANSI to overwrite the source file.
(Video tutorial recommendation: php video tutorial)
If you want to use utf-8 encoding, then php should output the header:
header(“Content-Type: text/html; charset=utf-8")
At the same time, the static page is added
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
and the encoding format of all files is utf-8.
The above is the detailed content of How to set encoding format in php. For more information, please follow other related articles on the PHP Chinese website!