Jump to content

get_headers() not performing like i expected


jasonc

Recommended Posts

I wish to find a way to test if multiple sites are up or not.

 

I have been using get_headers but it seems that this does not do what I thought I would.

 

I wish to know if the sites are down or not.

 

Is there another function that can test what state the site is in.

 

i.e.  server not found, server issues prevented the page from showing...

 

Using get_headers will still show the site is live even if the server is not found, due to server problems, if any.

 

 

With get headers, you can check the server's response code. And that would tell you if a site is up or not..

 

For example..

<?php
$url = 'http://google.com';

$status = get_headers($url);

if(strstr($status[0], '200'))
{
echo "Site Up";

} else {

echo "Site Down";
}

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.