<?php
// Initialize a URL to the variable
$url = "https://www.geeksforgeeks.org";
// Use get_headers() function
$headers = @get_headers($url);
// Use condition to check the existence of URL
if($headers && strpos( $headers[0], '200')) {
$status = "URL Exist";
}
else {
$status = "URL Doesn't Exist";
}
// Display result
echo($status);
?>
if(isset($_GET['id']))
{
// Do something
}
function urlExists($url=NULL)
{
if($url == NULL) return false;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if($httpcode>=200 && $httpcode<300){
return true;
} else {
return false;
}
}
print_r($_GET); // to check the parm list in url
if(isset($_GET['id']))
{
echo $_GET['id'];
// Do something
}