PHP get_headers not working?

前端 未结 1 1618
暖寄归人
暖寄归人 2021-01-15 19:32


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



        
相关标签:
1条回答
  • 2021-01-15 20:22

    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);
    
    0 讨论(0)
提交回复
热议问题