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 functions
Copy code The code is as follows:
header ("Content-type:text/html;charset=utf-8");
Example:
Copy code The code is as follows:
class home extends CI_Controller {
function index()
{
//Set encoding
header("Content-type:text/html;charset=utf-8");
echo 'test output';
}
}
?>
2. Use the Output class to solve the problem
Copy code The code is as follows:
$this->output->set_content_type('application/html;charset=utf-8 ');
$this->output->set_output("Test Output");
http://www.bkjia.com/PHPjc/788623.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/788623.htmlTechArticleWhen the controller echoes directly, some browsers will have garbled characters. You can use the following two methods to solve the problem: 1. Commonly used PHP header function. Copy the code. The code is as follows: header(...