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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.