TimesCoding

Learn, Practice, and Excel with our Coding Tutorials!

URL Exist or Not Exist Check PHP

June 9, 2022 1 Min read PHP

We can easily check a given URL or Link is active or not. By using below PHP function we can easily get whether the given URL is active or not active.

<?php

$url='https://timescoding.com/';

$array = get_headers($url);
$string = $array[0];
if(strpos($string,"200"))
  {
    echo 'URL Exist';
  }
  else
  {
    echo 'URL does not exist';
  }
Tags: URL URL Exist
Related Post:
Add HTTP Protocol if not Exist with URL −  The below function is used to add HTTP protocol to the URL if not available. You can add “http://” or “https://” by using the function.