ThinkPHP3.1 new features support for page compression output _php tutorial

Source: Internet
Author: User
Currently most browsers have supported the compression output of the page, by compressing the output, the page size can be reduced by 30%, but since both 3.0 and previous versions do not have built-in page compression output function, so generally speaking, developers need to add their own in the Portal file:

Ob_start (' Ob_gzhandler ');

However, due to the different server environment, sometimes this configuration conflicts with the zlib compression configuration in the php.ini file. ThinkPHP3.1 version of the built-in page compression output function, no longer need to manually add Ob_gzhandler code, add output_encode configuration parameters, and support detection zlib.output_compression.

The framework defaults to page compression output and automatically detects the Zlib.output_compression configuration, and if php.ini inside Zlib.output_compression is on, page compression is still done in the server environment.

The relevant code has only one line:

if (!ini_get (' zlib.output_compression ') && C (' Output_encode ')) Ob_start (' Ob_gzhandler ');

Under individual special circumstances, if an error message similar to the following appears:

In general, because your server is configured with other compression methods to cause conflicts, this time you can manually shut down the Output_encode, namely:

' Output_encode ' =>false

can solve the problem.

http://www.bkjia.com/PHPjc/825452.html www.bkjia.com true http://www.bkjia.com/PHPjc/825452.html techarticle currently most browsers have supported the compression output of the page, by compressing the output, the page size can be reduced by 30%, but because the 3.0 and previous versions have no built-in page compression output work ...

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