0

is there a script in php to check if a site exists in the world wide web?

  1. submit a url
  2. script check if site is existing
  3. return true if it does
yretuta
  • 7,963
  • 17
  • 80
  • 151
  • 1
    http://stackoverflow.com/questions/1545432/what-is-the-easiest-way-to-use-the-head-command-of-http-in-php – jason Nov 16 '09 at 07:03

3 Answers3

2

Here is an implementation using CURL:

Check website status using php and CURL library

Andrew Hare
  • 344,730
  • 71
  • 640
  • 635
1

You can just try to issue an HTTP request and see if something comes back.

Joey
  • 344,408
  • 85
  • 689
  • 683
  • uh...sorry for the noob question but what headers do I have to check to see if something comes back? – yretuta Nov 16 '09 at 07:05
  • Well, a response code of 200 would be a good start. And if no site exists then you'll probably not get anything but an error or a timeout. – Joey Nov 16 '09 at 07:11
0

Whilst firing off an HTTP request will tell you if a site exists, it doesn't tell you whether the domain has been registered but is not currently in use. If this is something that you'd need to be able to do, you need to use a WHOIS service to check whether the domain is registered or not.

ninesided
  • 23,085
  • 14
  • 83
  • 107