Home > Article > Backend Development > There are 3 methods for php to compress the ob_gzhandler function_PHP tutorial
This article will introduce you to the 3 methods of compressing the ob_gzhandler function in PHP. Friends who need to know the usage of the ob_gzhandler function may refer to it for reference.
There are 3 ways to use the ob_gzhandler function to compress PHP:
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’);
We can’t do the first method. The second method is good and can be done once and for all. The first and second methods have the same effect, which is to compress all php suffix files. I will mainly introduce the third method here,
Just try the CSS compression method, for example, compress style.css under the template
1. Copy style.css in the template directory and name it style.css.php
Then add this sentence at the top of style.css.php:
代码如下 | 复制代码 |
Add
at the end
代码如下 | 复制代码 |
2. Modify the css connection in header.php as follows
Original:
The code is as follows
|
Copy code
|
||||||||||||
Modified:
|