简体   繁体   English

Gzip压缩和未压缩的网页大小值

[英]Gzip compressed and uncompressed web page size values

I'm trying to build a feature to see the compressed level of a web page which already has Gzip installed on it. 我正在尝试构建一个功能来查看已经安装了Gzip的网页的压缩级别。 Similar to checkgzipcompression.com . 类似于checkgzipcompression.com

Where it displays the values, 在显示值的地方,
Uncompressed size: 5,174 bytes 未压缩大小:5,174字节

Compressed size: 1,826 bytes 压缩大小:1,826字节

How can I get these values through php? 如何通过php获取这些值? I tried with filesize function: 我尝试使用文件大小功能:

<?php
$url = 'http://www.example.com';
$fileSize = filesize($url);
print_r($fileSize);
?>

But it displays an error as shown below: 但它显示一个错误,如下所示:

Warning: filesize(): stat failed for http://www.example.com in C:\xampp\htdocs\projects\test.php on line 3

[replaced my domain with example.com]

How can I get it done? 我该怎么办?

My solution for you question 我为您解决的问题

$header = get_headers("http://wordpresskite.com", 1);
var_dump($header["Content-Length"]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM