Home >Backend Development >PHP Problem >How to set web page encoding in php
php method to set web page encoding: first open the PHP file; then add the code as "header("Content-Type:text/html;charset=utf-8");"; and finally save it.
Recommended: "PHP Video Tutorial"
PHP Settings Page Character Set utf-8
This requires the use of the header() function. The function of this function is to set the content of the response message.
If you want the browser to process the page according to UTF-8 encoding, you need to set the content-type field in the response message.
content-type is used to define the type of network file and the encoding of the web page, and determines the form and encoding in which the file recipient will read the file.
Just insert the following line of code into the PHP file, but be careful that there cannot be any output before the header() function.
header("Content-Type:text/html;charset=utf-8");
The above is the detailed content of How to set web page encoding in php. For more information, please follow other related articles on the PHP Chinese website!