is there a feature in php that would lt you get the header part of a site to check if it is up (for faster execution)? I use fopen("www.url.com", "r") but it take sometime to execute the script since I am doing a loop for 5 sites.
any possible (faster) idea would be greatly appreciated. Thanks.
Even requesting the header information only probably won't make much of a performance difference, because once the server responds it generally spews the HTML output pretty quickly. If you're making one request at a time, then you're going to have to wait for each to respond, or timeout, before moving on to the next.
However, you could have two seperate scripts. One (the slave) that makes the request and writes its findings to a file, and another (the master) that calls the first once for each site. This way the master script can run the slave script repeatedly, so you'll have multiple instances of the second script running at once all checking multiple web servers to see if their up. Once completed, the master script will check the file for the findings and report back to you.
I've never tried it myself, but I would imagine using exec() along with the & symbol at the end of your command-line would do it. Using the & symbol at the end of the command-line in Linux makes the command execute in the background and return control immediately. It may return control in a similar fashion when run using exec().
As was mensioned before your speedup would not be that much faster but you can either use the "HEAD" request in replace of the "GET" request or you could use "ETag" or "If-Modified-Since".
Just make sure you are requesting an HTML page. If you are requesting a dynamic page then all these methods will not work out of the box since your webserver will not know how to answer them and the logic must be built into the script.
I think your easiest is the "HEAD" request option. But really for your purposes just simply create an HTML page that simply contains "OK" and use your fopen method. An extra 2 bytes of data will not hit your time at all. Then you can simple see if you got "OK" returned.