Home >Backend Development >PHP Problem >What can be used to solve the problem of garbled characters in php?
What can I do to solve the problem of garbled characters in php?
Garbled characters in php can be solved by using the header() function.
The problem of Chinese garbled characters in pure PHP pages (the data is static)
If your PHP page has garbled characters, you only need to add the following code at the beginning of the page That's it.
<?php header("content-type:text/html;charset=utf-8"); //设置编码 ?>
HTML and PHP mixed page solution
How to mix HTML and PHP, in addition to following the operations mentioned in the first method, you also need Add this code at the top of the PHP file:
<?php header("content-type:text/html;charset=utf-8"); //设置编码 ?>
For more PHP related knowledge, please visit PHP Chinese website!
The above is the detailed content of What can be used to solve the problem of garbled characters in php?. For more information, please follow other related articles on the PHP Chinese website!