Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php check if url exists

<?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);
  
?>
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #php #check #url #exists
ADD COMMENT
Topic
Name
3+7 =