Verifying a URL

by raveendran 2010-01-28 14:28:03

<?php
$up = @fsockopen("www.hiox.com", 80, $errno, $errstr, 30);
if($up)
{
echo "Valid URL";
}
else
{
echo "Invalid URL";
}
?>

The fsockopen() function actually tries to connect a socket to the listed site. The first parameter listed "www.hiox.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.

Tagged in:

945
like
0
dislike
0
mail
flag

You must LOGIN to add comments