Home > Backend Development > PHP Problem > How to use header to set encoding in php

How to use header to set encoding in php

王林
Release: 2023-03-04 19:08:01
Original
3098 people have browsed it

php uses header to set the encoding method: add the code [header("content-type:text/html; charset=xxx")] at the head of the script. If you want to set UTF-8 encoding, the value of the charset attribute should be UTF-8.

How to use header to set encoding in php

The header() function sends raw HTTP headers to the client.

(Recommended tutorial: php graphic tutorial)

Example:

header("content-type:text/html; charset=xxx");
Copy after login

Implementation code:

The php page is utf encoded

header("Content-type: text/html; charset=utf-8");
Copy after login

(Video tutorial recommendation: php video tutorial)

php page is gbk encoded

header("Content-type: text/html; charset=gb2312");
Copy after login

php page is big5 Coding

header("Content-type: text/html; charset=big5");
Copy after login

The above is the detailed content of How to use header to set encoding in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template