PHP determines whether the page file has been compressed by gzip

*文
Release: 2023-03-19 06:06:01
Original
1823 people have browsed it

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); ?>
Copy after login

Use get_headers to determine whether to use gzip compression

Copy after login

Test results:

When ob_gzhandler is added, true is returned, and false is returned after deletion

2. Use curl

Picture

Copy after login

Use curl to determine whether to use gzip compression

Copy after login

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

PHP output gzip compression

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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!