How does php determine whether the page file has been gzip compressed? This article mainly explains how PHP determines whether a page or image has been compressed by gzip. Share it with everyone for reference. I hope to be helpful.
Use php to determine whether the page or image has been compressed by gzip
1. Use get_headers
Page content
'one','value'=>1), array('name'=>'two','value'=>2), array('name'=>'three','value'=>3) ); header('content-type:application/json'); echo json_encode($data); ?>
Use get_headers to determine whether to use gzip compression
Test results:
When ob_gzhandler is added, true is returned, and false is returned after deletion
2. Use curl
Picture
Use curl to determine whether to use gzip compression
Test results:
When ob_gzhandler is added, true is returned, false is returned after deletion
##Related recommendations :
2 ways to enable gzip compression in php code
html writing method to gzip compression rate Impact
The above is the detailed content of PHP determines whether the page file has been compressed by gzip. For more information, please follow other related articles on the PHP Chinese website!