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
   

PHP ARTICLES

- 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...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 4 - Follow our Sitemap

Dev Shed Tutorial Topics: