Function get_headers()
does not give an array with the same indexes when I make a change in domain. When and why does this occur?
I want Content-Length
value for hundreds of domains. What changes do I need to make?
<?php
$url = 'http://www.ecomexpomelbourne.com.au/sponsors/';
echo "<pre>";
$domain_data[] = array();
$domain_data = get_headers( $url, 1 );
print_r($domain_data);
echo $domain_data['Last-Modified'];
?>
When used for current page url I get Content-Length index
Sometimes the server just does not send the Content-length
header, and you should expect and treat properly such cases, as there are such provisions described in RFC2616.
In some situations, when the page is dynamically generated (with PHP or other language), the length of the body is not known yet at the stage of the sending of headers, so there is no way for the server to generate proper Content-length
header in advance. But there are also cases when the Content-length
header is explicitly forbidden to be sent.