How to check if the given IP address is valid or not?; In this post, I will teach you how to validate IP address for the incoming request. This is too much important while we collect sensitive data from the HTTP incoming request.
For check valid IP address we will take help of PHP function filter_var(). This function will return a boolean datatype. If the given IP address is valid then it will return true else this function will return false.
This IP validate function will check in a different way like a given string has "." available and also check with valid digits and base on that it will return the result.
Valid IP check using PHP given PHP function we must need to pass two arguments. In the first argument, we will pass the IP address string, and the second argument we will pass the type of check with the given IP address. So lets with an example.
How To Check Given URL Is Valid Or Not PHP Function Example
<?php $ip = "127.0.0.1"; if (!filter_var($ip, FILTER_VALIDATE_IP) === false) { echo("$ip is a valid IP address"); // TRUE } else { echo("$ip is not a valid IP address"); }
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 :
- Zaakpay Payment gateway Integration Tutorial PHP
- Simple WhatsApp Messages Send Using Chat API In PHP
- How To Check Valid Ip Address Using PHP Function Example
- Slug PHP Function Example - slugify($string)
- PHP Post Request cURL Example With Authentication
- Error : Trying To Get Property Of ID Non-Object All Possible Solution Guideline In Laravel - PHP
- How To Add Google reCAPTCHA v3 In HTML Form Based PHP/Laravel Website
- Generate Captcha Code Image With Form Validation - PHP
- Zoom API Integration with PHP
- IOS Push Notification Send Example