Using PHP to validate an IP address

You can use the PHP code below to check if an IP address is valid or not.

$ip = ""; //enter a valid or invalid ip address here if(filter_var($ip, FILTER_VALIDATE_IP)) { // The IP Address is valid } else { // The IP Address is not valid }
Code language: PHP (php)

Wasn’t that easy!?!

Tags:
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments