Home  >  Article  >  Backend Development  >  How to solve Chinese garbled characters in php ci

How to solve Chinese garbled characters in php ci

藏色散人
藏色散人Original
2021-07-12 09:44:161909browse

Solution to Chinese garbled characters in php ci: 1. Set "charset=utf-8"" through the header function of php; 2. Use the Output class to solve the garbled code problem.

How to solve Chinese garbled characters in php ci

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

php ci How to solve Chinese garbled characters?

CodeIgniter Two solutions for outputting Chinese garbled characters

When the controller echoes directly, some browsers will have garbled characters. This article mainly introduces two solutions for CodeIgniter to output Chinese garbled characters. Friends who need it You can refer to the following

When the controller echoes directly, some browsers will have garbled characters. You can use the following two methods to solve it:

1. Commonly used PHP header function

The code is as follows:

header("Content-type:text/html;charset=utf-8");

Example:

The code is as follows:

2. Use the Output class to solve the problem

The code is as follows:

$this->output->set_content_type('application/html;charset=utf-8');
$this->output->set_output("测试输出");

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to solve Chinese garbled characters in php ci. 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