Whenever it is required to get some input url from user then the first things comes is checkwhether that url is working and valid or it is not working.
<?php
//php function to check whether the url exists or not and validate it
function check_url($url)
{
$check = @fopen($url,"r"); // we are opening url with fopen
if($check)
$status = true;
else
$status = false;
return $status;
}
?>
<?php
//$url = $_GET["url"]; // you can get the parameter from GET
$url = "http://www.techpdf.in";
if(check_url($url))
{
echo "<div><a href=$url>$url</a> is a <b>valid</b> URL</div>";
}
else
{
echo "<div><a href=$url>$url</a> is a <b>invalid</b> URL</div>";
}
?>
so after execution it will show the message as
http://www.techpdf.in is a valid URL.
http://www.techpdf.in is a valid URL.
No comments:
Post a Comment