get_headers()检查站点是否在线有多可靠? [关闭]

How reliable is get_headers() for checking if a site is online?

Basically:

    $check = get_headers($url,1);

So again how reliable is it and can I depend on its accuracy?

If you want to use the results of get_headers() for input to any other function I would not count on 100% accuracy. If you want to look at the results with your own eyes (like I do) and fix or check any discrepancies yourself, then this will be fine.

The results can be effected by a number of things for both get_headers() and cURL. Personally I run cURL against an array of all the websites I manage at least once a day while I am at work and typically I get a few false negatives. I used to use the get_headers() method, but in terms of false negatives I didn't notice any difference. The reason I switched to cURL was it gave better options in terms of returning error messages etc.

NOTE: If, like me, you are running this against an array of sites you manage I should point out that on many occasions this approach has caused me to get sucked into the blacklist from my hosting provider because I was running this at the same time that they were detecting a brute force attack from elsewhere. Some phone calls to tech support and after a few weeks they began recognize me when I called... not a good thing.