PHP get_headers not working?

倖福魔咒の 提交于 2019-12-19 10:52:34

问题



I want to get headers of website but get_headers return nothing
This is my code

<?php
$url = 'http://www.example.com';

print_r(get_headers($url));
?>

For your information my web hosting provider is network solution
Does the problem from my code or from the web hosting provider ?
And what's the solution to get the headers of one website ?


回答1:


If get_headers is disabled then you can also use cURL instead.

$curl = curl_init();
curl_setopt_array($curl, array(    
    CURLOPT_URL => $url,
    CURLOPT_HEADER => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_NOBODY => true));

$header = explode("\n", curl_exec($curl));
curl_close($curl);

print_r($header);


来源:https://stackoverflow.com/questions/23844680/php-get-headers-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!