How to set character encoding in php

王林
Release: 2023-03-04 09:56:01
Original
17489 people have browsed it

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

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

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!

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