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