Bladephp: Now with 8+ codeigniter, php, and laravel project 8+ php project From $37/Month From Rs. 2499/Month

How to PHP Validate URL

by
Category:php
php
How to PHP Validate URL

When a URL is submitted from a form input by the user, it is very important to check this URL is valid or not before taking any action on it. Here we’ll provide the simple PHP code to validate a URL in PHP.

Code

$website = $_POST["website"];
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$website)) {
  $message = "Invalid URL";
}

0 Comments


Html code work in comment box


Related Post