PHP
  Home arrow PHP arrow Creating a Validation Helper Class
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

Creating a Validation Helper Class
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 4
    2009-08-17


    Table of Contents:
  • Creating a Validation Helper Class
  • Review: a URL-handling helper class
  • Creating a validation class
  • Validating alphabetic and alphanumeric 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


    Creating a Validation Helper Class
    ( Page 1 of 4 )

    Helper classes seem easy to build -- almost deceptively so. If you're building a helper class to assist with a crucial function, however, such as validation, the approach you need to take may seem a bit less straightforward. This fifth article in an eight-part series on building helper classes walks you through the process, complete with hands-on examples.

    True to form, for any PHP developer with only an average background in the object-oriented paradigm, building helper classes should be a pretty straightforward task. After all, this process doesn’t demand the effort required for creating a full-blown library.

    It’s fair to say, though, that even when a helper is designed to perform certain tasks that at least in theory shouldn’t be extremely complex, in practice things can get a bit intimidating. The reason for this is simple: there are times when a helper class needs to implement methods or functions that play a role as crucial as a much larger module or plug-in.

    Of course, speaking in practical terms, categorizing a particular class as a helper or as a core library depends strongly on the context in which it will be used. But regardless of its rather intangible nature, helpers are undeniably a fundamental part of a PHP developer’s toolbox.

    Therefore, if you’re interested in arming yourself with the right tools to start building your own helper classes in PHP 5 with minor efforts, then don’t hesitate any longer; begin reading this series of articles right away!

    Before you skip over this introduction, however, it would be helpful to recall that I left off the previous article discussing how to create a URL helper class whose main functionality was implemented around the $_SERVER PHP superblobal array. Despite the simplicity of many of its methods, the class demonstrated how to utilize it without having to deal with any instances of it, since the methods were declared static, and therefore used out of the object context.

    Nonetheless, this journey through the ins and outs of building helper classes with PHP 5 hasn’t finished yet. In this fifth part of the series I plan to build a class that will be responsible for validating input data, either supplied by users or from a different source.

    In this specific project, this validation helper will make use of the PHP filter extension to perform the pertinent checking processes, but it can be easily adapted to use custom methods as well.

    Now, it’s time to leave the theory behind us and start learning how to create a helper class to validate input data. Let’s go!



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

       

    PHP ARTICLES

    - Adding Ordering and Grouping Clauses to the ...
    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - 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...





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