Two solutions to CodeIgniter output Chinese garbled _php tutorial

Source: Internet
Author: User
Tags codeigniter
When the controller is directly echo, some browsers will appear garbled. The following two methods can be used to solve the problem:

1, commonly used in the header function of PHP

Copy the Code code as follows: Header ("Content-type:text/html;charset=utf-8");

Example:

Copy the Code code 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

Copy the Code code as follows: $this->output->set_content_type (' application/html;charset=utf-8 ');
$this->output->set_output ("Test output");

http://www.bkjia.com/PHPjc/788623.html www.bkjia.com true http://www.bkjia.com/PHPjc/788623.html techarticle when the controller is directly echo, some browsers will appear garbled. can be resolved in the following two ways: 1, the common PHP header function copy code is as follows: Header ( ...)

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.