Home > Article > Backend Development > How to set php header encoding
In PHP, you can set the encoding by adding the "header("Content-type: text/html; charset=utf-8");" statement to the header of the PHP file.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
How to set the php header encoding?
The code for setting utf encoding is as follows:
header("Content-type: text/html; charset=utf-8");
Note: Usually the above code is placed on the home page of the php page
The header() function sends the original to the client HTTP header.
Attachment:
The php page is encoded by gbk
header("Content-type: text/html; charset=gb2312");
The php page is encoded by big5
header("Content-type: text/html; charset=big5");
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to set php header encoding. For more information, please follow other related articles on the PHP Chinese website!