PHP file_get_contents very slow when using full url

后端 未结 9 1078
我在风中等你
我在风中等你 2020-11-27 12:10

I am working with a script (that I did not create originally) that generates a pdf file from an HTML page. The problem is that it is now taking a very long time, like 1-2 mi

9条回答
  •  悲哀的现实
    2020-11-27 12:41

    Sometimes, it's because the DNS is too slow on your server, try this:

    replace

    echo file_get_contents('http://www.google.com');
    

    as

    $context=stream_context_create(array('http' => array('header'=>"Host: www.google.com\r\n")));
    echo file_get_contents('http://74.125.71.103', false, $context);
    

提交回复
热议问题