PHP
  Home arrow PHP arrow Using Filters in PHP 5
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Using Filters in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 7
    2009-07-15


    Table of Contents:
  • Using Filters in PHP 5
  • Filters available in PHP 5
  • Checking for integer values with the filter PHP extension
  • Using the FILTER_VALIDATE_INT filter to check for minimal and maximal values

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Using Filters in PHP 5
    ( Page 1 of 4 )

    You've probably built custom functions and libraries to validate user input in PHP 5. There's an easier way to do this, and it can save you considerable time and effort. It involves using PHP 5's own built-in and often-neglected filters. This nine-part series will introduce you to their use.

    Definitely, one of the most common tasks that PHP programmers have to tackle during the development of web applications is validating user-supplied data. This fact brings up a crucial and mandatory rule: the client side is always non-trusted terrain with little or no control. Consequently, any data coming from it needs to be properly filtered and thoroughly checked before doing something useful with it.

    Fortunately, the introspective capabilities offered by PHP allow you to check incoming data in a pretty straightforward way. It comes packaged with a number of native functions, which you’ve surely used hundreds of times before, that permit you to verify different data types very easily. These data types include strings and float numbers, integers, arrays and objects. This neat set of functions, along with some extra features bundled exclusively with PHP 5, such as type hinting, allow developers build libraries that can be used for checking empty strings and numeric ranges, email addresses and URLs, and so forth.

    Purely aside from these other developer-built libraries, however, PHP 5 also includes by default a useful library that allows you to perform all of these types of validation tasks by means of a bunch of native filters. Yes, these rather overlooked filters will let you check for integers and float numbers, URLs, email addresses, etc., even more easily than by using your own custom functions. Best of all, they don’t require any additional configuration.

    Indeed, the use of native PHP filters may contribute significantly to saving time and effort when it comes to validating input data. In this series of articles I’m going to attempt to provide you with a concise guide to how to use them, as usual by way of a decent variety of code samples.

    So, now that that you know what to expect from this group of articles, it’s time to move forward and start discovering the real power that stands behind using filters in PHP 5. Let’s begin now!



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

       

    PHP ARTICLES

    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek