Home  >  Article  >  Backend Development  >  What can be used to solve the problem of garbled characters in php?

What can be used to solve the problem of garbled characters in php?

藏色散人
藏色散人Original
2019-10-17 10:18:553166browse

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!

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