Home  >  Article  >  Backend Development  >  How to set character set in php

How to set character set in php

王林
王林Original
2020-11-04 10:07:263092browse

How to set the character set in php: directly add the code [header('Content-type:text/html;charset=utf-8');] to the header of the php file.

How to set character set in php

If there is a problem with the character encoding displayed in our php file in the browser, such as garbled characters, then you can add the following code to the php file to solve this problem question.

(Learning video recommendation: java video tutorial)

The code is as follows:

<?php
    // 服务器读取的  编码设置
    header(&#39;Content-type:text/html;charset=utf-8&#39;);
?>

Related recommendations: php training

The above is the detailed content of How to set character set 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