php
Validate IP address using filter_var() method PHP
You can use filter_var() with FILTER_VALIDATE_IP to validate an IP address in PHP. Below is the code example for that.
<?php
$ip_address = "168.0.0.1";
if (filter_var($ip_address, FILTER_VALIDATE_IP) == true) {
echo("Valid IP");
} else {
echo("Invalid Ip");
}
?>
Was this helpful?
Similar Posts
- Validate a number using filter_var() method in PHP
- How to Use PHP to Get the Client IP Address
- Send POST request without using curl using PHP 5+
- Convert characters to lowercase using strtolower() function in PHP
- Calculate length of a string using strlen() function in php
- Connect Mysql and PHP using mysqli
- Get last insert id in db using PHP