Home  >  Article  >  Backend Development  >  How to set php header encoding

How to set php header encoding

藏色散人
藏色散人Original
2021-09-11 10:21:262169browse

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.

How to set php header encoding

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!

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