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

How to set encoding format in php

王林
Release: 2023-03-04 12:38:02
Original
6292 people have browsed it

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.

How to set encoding format in php

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")
Copy after login

At the same time, add

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
Copy after login

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")
Copy after login

At the same time, the static page is added

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Copy after login

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!

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