dtoq41429 2017-10-22 22:23
浏览 283
已采纳

get_headers方法的http 500错误

My site went down recently and the hosting company helped recover it. After that i keep getting this error on one of my pages.

[22-Oct-2017 02:54:03 UTC] PHP Fatal error:  Cannot redeclare get_headers() in C:\inetpub\vhosts\mysite.com\httpdocs\html\blue\inc\ip_redirect.php on line 92

Here is the method that the code is referring to. I did check and this is whats causing the HTTP 500 errors.

function get_headers($url,$format=0)
{
    $url=parse_url($url);
    $end =  "

";
    $fp = fsockopen($url['host'],  (empty($url['port'])?80:$url['port']), $errno, $errstr, 30);
    if  ($fp)
    {
        $out  = "GET / HTTP/1.1
";
        $out .= "Host:  ".$url['host']."
";
        $out .= "Connection: Close

";
        $var  =  '';
        fwrite($fp, $out);
        stream_set_timeout($fp, 5);

        while (!feof($fp))
        {
            $var.=fgets($fp,  1280);
            $info = stream_get_meta_data($fp);

             if ($info['timed_out']) {
                echo 'Connection timed out!';
                return "";
             }

            if(strpos($var,$end))
            break;
        }
        fclose($fp);
        $var=preg_replace("/

.*\$/",'',$var);
        $var=explode("
",$var);
        if($format)
        {
            foreach($var  as $i)
            {
                if(preg_match('/^([a-zA-Z -]+):  +(.*)$/',$i,$parts))
                $v[$parts[1]]=$parts[2];
            }
            return  $v;
        }
        else
            return $var;
    }
}
  • 写回答

1条回答 默认 最新

  • duanjiang7505 2017-10-22 22:39
    关注

    The method get_headers is an internal function from PHP.

    http://php.net/manual/en/function.get-headers.php

    The method looks like some sort of polyfill. You have to either remove this method, or wrap it in a function_exists statement.

    If none are options, than you might want to reach out to this scary method. Haven't used it myself. http://php.net/manual/en/function.runkit-function-remove.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号