Testing if a website exists

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jclarke
Forum Newbie
Posts: 4
Joined: Wed Jun 21, 2006 3:43 am

Testing if a website exists

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Having a domain doesn't mean it would respond to a page request. I'd suggest using a WHOIS request.
jclarke
Forum Newbie
Posts: 4
Joined: Wed Jun 21, 2006 3:43 am

Post 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?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

cURL maybe?
jclarke
Forum Newbie
Posts: 4
Joined: Wed Jun 21, 2006 3:43 am

Post by jclarke »

what might cURL be?
User avatar
bmcewan
Forum Commoner
Posts: 55
Joined: Wed Jun 02, 2004 7:19 am
Location: West Yorkshire, UK.

Post 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.
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post 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.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post 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.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Sorry, my mistake.
Post Reply