Home arrow PHP Tutorials

Translate This Website
Sunday, 07 September 2008
Web Development
Request a Quote
Script Categories
RSS Media Grabber Funny Videos & Pictures Life Stories (Flash) Video Search & Download Video Downloader Script Country on Sale Advanced Polls Phone Upload/SMS Scripts PhotoCube Script SlideShow Creation Script Make Confessions Scripts Guitar Tabs Scripts Create Custom Smiley Script Short URLs & Subdomains Hot Or Not Game Scripts Put your text on images Watermark & Image Hosting Joomla Components Low Cost Scripts
Partners
WEBSITE TRAFFIC
Pissed Customers
Credit Cards
Broadband Tweaks & Info
eBay Sniping Software
Custom Programming
Scripts and Stuffs
Hot php scripts
Add your scripts
Script Search
php scripts directory
script heaven
the cgi site
Scripts
Software Development
Free Icons
SEO Services


Verifying a URL Print E-mail

Learn how to see if a URL is valid. and still alive or if it's a 404 Not Found

 


Problem:

You have a thousands of links just randomly lying around from back in the day and you want to only put the ones up which still exist, and not the ones which don't exist anymore, what do you do?

Answer:

Not a problem bub, just use the power of PHP by using the fsockopen() function to check and see if the site is up and you'll be set:

<?
$up = @fsockopen("www.spoono.com", 80, $errno, $errstr, 30);
if($up)
{
echo "<a xhref=\"http://www.spoono.com\">Spoono</a>";
}
else
{
echo "<a xhref=\"http://www.spoono.com\">Spoono's Dead!! :(</a>";
}
?>

The code is fairly simple and easy to follow. The fsockopen() function actually tries to connect a socket to the listed site. The first parameter listed "www.spoono.com" would be the URL of the website you want to check. It is important that you do not put http:// in front of the URL or else the script does not work. The second parameter, 80, would be the port, which should just be left alone. The next two parameters are just standard PHP errors, and the last one, 30, is the amount of time to wait in seconds before assuming its a timeout. The next few lines checks to see if the connection went through and if it did then put the link up. Again, an easy and useful script.


Well, that's all folks. Not too tough was it? Well thats it folks. I hope it works out for you and if it doesn't, post on the board and we'll try to help you out.

 

Credit: www.spoono.com 





Reddit!Del.icio.us!Facebook!Slashdot!Netscape!Technorati!StumbleUpon!Newsvine!Furl!Yahoo!Ma.gnolia!Free social bookmarking plugins and extensions for Joomla! websites!
 
< Prev   Next >
Services
Script Installation
Hosting
Free Image Hosting
PageRank Checker
Login Form
On Sale
Funny Videos and Pictures Script
Funny Videos and Pictures Script
$69.00
$59.00
You Save: $10.00
Add to Cart
Home Announcements Support Newsletter Forum PHP Articles PHP Tutorials Scripts FAQs Free Scripts Links Contacts
Copyrighted © 2008 phppod.com