There are 3 ways to compress Ob_gzhandler functions in PHP _php tutorials

Source: Internet
Author: User
This article to introduce to you about PHP compression Ob_gzhandler function There are 3 ways, there is a need to understand the Ob_gzhandler function usage of friends do not go into the reference.

There are 3 ways to compress PHP using the Ob_gzhandler function:

1. Set Output_handler = Ob_gzhandler in php.ini
2. Add Php_value output_handler Ob_gzhandler in. htaccess
3, add Ob_start (' Ob_gzhandler ') in PHP file header;

The first kind we can't do, the second method is good, can once and for all, one or two methods of the same effect, that is, all the php suffix file compression. Here I mainly introduce the third method
is to try the CSS compression method, for example, to compress the style.css under the template

1, the template directory under the style.css copy out, named style.css.php

Then add this sentence at the top of the style.css.php:

The code is as follows Copy Code

At the end add

The code is as follows Copy Code

2. Modify the CSS connection in header.php as follows

The original:

The code is as follows Copy Code


Modified by:

The code is as follows Copy Code


Done, now your CSS can be compressed by gzip.

JS can also use the same method, but in the xx.js.php head added should be this:

The code is as follows Copy Code

(When copying, remove the space before PHP)

Take a closer look at the JS in the K2 theme, that is, modify the suffix to PHP and add the Ob_gzhandler function at the top.

http://www.bkjia.com/PHPjc/631509.html www.bkjia.com true http://www.bkjia.com/PHPjc/631509.html techarticle this article to introduce to you about PHP compression Ob_gzhandler function There are 3 ways, there is a need to understand the Ob_gzhandler function usage of friends do not go into the reference. There are 3 ways to use the Ob_gzhandler function ...

  • Related Article

    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.