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.
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!