Home  >  Article  >  Backend Development  >  How to set encoding format in php

How to set encoding format in php

王林
王林Original
2020-08-13 14:04:266247browse

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")

At the same time, add

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

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")

At the same time, the static page is added

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

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!

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