Jump to content

PHP IP Address Validation


musclehead

Recommended Posts

My head is spinning trying to figure out the correct syntax to do a regex to validate an IP address. I'm dealing w/ a /16 class network, so I only need to worry about the last 2 segments of the IP address and ensure they are valid (0-254).

 

I have a simple comparison against the first 2 segments, as they will always be the same, but I'm trying to get a regular expression to check the last 2 segments of the IP address to ensure they're valid.

 

I'd post code I've tried, but it's a mess...so I'll spare everyone the horror. Thanks!!!

Link to comment
https://forums.phpfreaks.com/topic/105440-php-ip-address-validation/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.