How to solve Chinese garbled characters in php ci

藏色散人
Release: 2023-03-11 12:42:02
Original
1971 people have browsed it

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");
Copy after login

Example:

The code is as follows:

Copy after login

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("测试输出");
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template