Page 1 of 1

Testing if a website exists

Posted: Sun Aug 13, 2006 3:00 am
by jclarke
I'm making a sort of domain searcher.
Basically the user types in a text box the domain that the want to see is available or not.

The only thing I tried was this:

Code: Select all

if(file_exists($url)) {
That didn't work

Does anybody know how to do this???

-thanks

Posted: Sun Aug 13, 2006 3:06 am
by feyd
Having a domain doesn't mean it would respond to a page request. I'd suggest using a WHOIS request.

Posted: Sun Aug 13, 2006 3:13 am
by jclarke
ok well I don't really need a domain I just need to check if any address that the user types in exists.
Is that at all possible?

Posted: Sun Aug 13, 2006 3:21 am
by RobertGonzalez
cURL maybe?

Posted: Sun Aug 13, 2006 3:48 am
by jclarke
what might cURL be?

Posted: Sun Aug 13, 2006 6:53 am
by bmcewan
you might want to check out this

http://uk.php.net/manual/en/ref.curl.php

Also you would need your installation of php to be compiled with curl, use phpinfo() to find out if it has been installed on your server.

Posted: Sun Aug 13, 2006 9:43 am
by bokehman
cURL? What for? gethostbynamel() returns false if there is no "A" record and if you really want to be precise get the document status.

Posted: Sun Aug 13, 2006 10:37 am
by RobertGonzalez
Nice function, gethostbyname(). Honestly, I didn't know it existed (see, you learn something everyday here). But make sure to read the user comments, specifically about caching, as this might affect the performance of your checking.

Posted: Sun Aug 13, 2006 10:47 am
by bokehman
Everah wrote:Nice function, gethostbyname(). Honestly, I didn't know it existed (see, you learn something everyday here). But make sure to read the user comments, specifically about caching, as this might affect the performance of your checking.
not gethostbyname()! I was recomending gethostbynamel() which returns false on failure. Note the "L" at the end.

Posted: Sun Aug 13, 2006 10:54 am
by RobertGonzalez
Sorry, my mistake.