Home >Backend Development >PHP Problem >How to set gbk encoding in php?
php method to set gbk encoding: In the head of the PHP file, add the "header("Content-type: text/html; charset=gb2312");" code to declare the content-type and define the web page Encode to gbk encoding and save it.
Recommended: "PHP Video Tutorial"
php set gbk encoding
If you want to use gbk encoding, then php should output the header: header("Content-Type: text/html; charset=gb2312")
, add 387ddc5f9a52da5113ec00c23b62286d
, the encoding format of all files is ANSI, you can open it with Notepad, save as, select the encoding as ANSI, and overwrite the source file.
If you want to use utf-8 encoding, then php should output the header: header("Content-Type: text/html; charset=utf-8")
, add ## to the static page #3dac93479e15392607bc2263a9a9421e, the encoding format of all files is utf-8.
header() declares content-type
header(“Content-Type: text/html; charset=gb2312")Content-Type (content type), generally refers to the Content-Type that exists in the web page, used for Defining the type of network file and the encoding of the web page determines the form and encoding in which the browser will read the file. This is why we often see that the result of clicking on some PHP web pages is to download a file or a picture. The Content-Type header tells the client the content type of the actual content returned. Grammar format:
Content-Type: text/html; charset=utf-8 Content-Type: multipart/form-data; boundary=somethingExample: Common media format types are as follows:
multipart/form-data: When you need to upload files in a form, you need to use this format
The above is the detailed content of How to set gbk encoding in php?. For more information, please follow other related articles on the PHP Chinese website!