How to Validate a Website URL in PHP

How can I use PHP to check if the URL is a valid link or just a normal text.

You can use PHP native function – filter_var to check if the string is normal test or a valid URL. Here is the example
if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) {
    die('Its a invalid URL');
}

Leave a Reply

avatar
  Subscribe  
Notify of