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.

 

 

Link to comment
Share on other sites

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";
}

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.