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

How to set character encoding in php

王林
王林Original
2020-08-11 14:44:0217499browse

How to set character encoding in php: Add content [header("Content-Type: text/html;charset=utf-8");] at the beginning of the php file. The header() function is used to send raw HTTP headers to the client.

How to set character encoding in php

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

(Recommended tutorial: php graphic tutorial)

Syntax:

header(string,replace,http_response_code)

Parameters:

  • string Required. Specifies the header string to be sent.

  • replace Optional. Indicates whether this header replaces the previous header, or adds a second header. Default is TRUE (replacement). FALSE (allow multiple headers of the same type).

  • http_response_code Optional. Forces the HTTP response code to the specified value. (PHP 4.3 and higher versions are available)

(Recommended video tutorial: php video tutorial)

Just add the following content at the beginning of the file :

header("Content-Type: text/html;charset=utf-8");

The above is the detailed content of How to set character encoding 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