How to check whether the given URL is valid or not?; In this post, I will learn you how to check given given URL is a valid URL or not validate. This is very simple a PHP function will help us to check valid URLs.
Using PHP function filter_var(), This function will check and return boolean true if the URL is valid else it will return false. After Having This post you will easy to check URL using PHP function.
To check a valid URL in PHP, We need to pass two arguments in this function. In the first argument, we will pass the URL which we what to check and in the second argument need to pass type to check from the given string using this function.
How Do Check Whether The Email Address Valid Email Or Not In PHP Example
<?php
$url = "https://www.webappfix.com";
//First we will Remove all illegal characters from a url
$url = filter_var($url, FILTER_SANITIZE_URL);
// Validate url
if (!filter_var($url, FILTER_VALIDATE_URL) === false) {
echo("$url is a valid URL"); // TRUE
} else {
echo("$url is not a valid URL");
}
We always thanks to you for reading our blogs.
Dharmesh Chauhan
(Swapinfoway Founder)Hello Sir, We are brothers origin from Gujarat India, Fullstack developers working together since 2016. We have lots of skills in web development in different technologies here I mention PHP, Laravel, Javascript, Vuejs, Ajax, API, Payment Gateway Integration, Database, HTML5, CSS3, and Server Administration. So you need our service Please Contact Us
Haresh Chauhan
(Co-Founder)We Are Also Recommending You :
- Firebase Notification Send Example
- Error : Trying To Get Property Of ID Non-Object All Possible Solution Guideline In Laravel - PHP
- Zoom API Integration with PHP
- IOS Push Notification Send Example
- Upayments Gateway Integration PHP - Laravel
- UPI Payment Gateway Integration in PHP/Laravel
- How to connect database with php
- Get Full Address From Latitude Longitude Google Map API In PHP
- Firebase Dynamic Links Shorten URL PHP Function
- Create Database In MYSQL Using PHP Script Example