ThinkPHP3.0 and earlier versions do not have the built-in page compression output function. manually adding code settings may conflict with the php configuration environment. The new ThinkPHP3.1 feature adds support for page compression output, for more information, see. most browsers currently support page compression. by compressing the output, the page size can be reduced by 30%, however, since neither version 3.0 nor earlier has the built-in page compression output function, developers generally need to 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_ENCODE')) 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.