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 :
- Php Questions for Interview
- How To Add Google reCAPTCHA v3 In HTML Form Based PHP/Laravel Website
- Firebase Notification Send Example
- Adding Watermark On Image In PHP Example
- Generate Captcha Code Image With Form Validation - PHP
- How To Check Valid Integer Values Using PHP Function Example
- Create Database In MYSQL Using PHP Script Example
- PhonePe Payment Gateway Example PHP
- Upayments Gateway Integration PHP - Laravel
- Match Function Php 8