Home arrow PHP arrow Validating IP Addresses with Filters in PHP 5

Validating IP Addresses with Filters in PHP 5

If you’re a PHP developer who wishes to learn how to take advantage of the solid functionality provided by the filter extension that comes with PHP 5, then look no further, because you’ve come to the right place. Welcome to the seventh part of a nine-part series that gets you started using the most useful validation filters included with this PHP library.

TABLE OF CONTENTS:
  1. Validating IP Addresses with Filters in PHP 5
  2. Review: the FILTER_VALIDATE_URL filter
  3. Introducing the FILTER_VALIDATE_IP filter
  4. Checking for IPv6-compliant addresses
By: Alejandro Gervasio
Rating: starstarstarstarstar / 3
August 26, 2009

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

And now that you know what to expect from this group of articles, it's time to review the concepts discussed in the last installment. In that article I explained how to use the filter extension for validating URLs in a truly painless fashion.

Indeed, the combination of the "filter_var()" function and the FILTER_VALIDATE_URL filter allowed us to easily determine if certain portions of a given URL, such as its host, paths and query strings, were valid. You can surely appreciate this functionality when developing modules, classes, plug-ins, etc. that must perform some kind of strong validation on incoming data.

The filter extension comes armed with another handy filter, though, that permits you to check some common things, such as the IP addresses of client machines. Thus, assuming that you're interested in learning how to accomplish this task without suffering premature hair loss, in the next few lines I'm going to discuss in depth the use of the FILTER_VALIDATE_IP filter. As you'll see in a moment, it is quite easy to master.

Now, let's get rid of the preliminaries and start seeing how to get the most of this powerful PHP 5 filter. Let's jump in!



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: