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.
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!