Currently, most browsers support page compression output. By compressing the output, the page size can be reduced by 30%. However, since 3.0 and earlier versions do not have the built-in page compression output function, generally, developers must add the following in the entry file:
Ob_start ('ob _ gzhandler ');
However, due to different server environments, sometimes this configuration conflicts with the zlib compression configuration in the php. ini file. ThinkPHP3.1 has built-in page compression and output functions. You do not need to manually add ob_gzhandler code, add OUTPUT_ENCODE configuration parameters, and support detection of zlib. output_compression.
By default, the Framework compresses the page output and automatically detects zlib. output_compression configuration, If php. zlib in ini. when output_compression is enabled, the page is still compressed by PAGE compression in the server environment.
There is only one line of related code:
If (! Ini_get ('zlib. output_compression') & C ('output _ encoding') ob_start ('ob _ gzhandler ');
In some special environments, if an error message similar to the following occurs:
Output_handler "ob_gzhandler" conflicts with "zlib. output_compression"
This is generally because your server is configured with other compression methods, which leads to conflicts. In this case, you can manually disable OUTPUT_ENCODE, that is:
'Output _ encode' => false
You can solve the problem.