PHP
  Home arrow PHP arrow Building Helpers 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

Building Helpers in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 4
    2009-07-20


    Table of Contents:
  • Building Helpers in PHP 5
  • Building a helper in PHP 5
  • Extending the functionality of the text helper class
  • The text helper class in action

  • 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


    Building Helpers in PHP 5
    ( Page 1 of 4 )

    Tired of repetitive coding for tasks such as generating web site breadcrumbs? PHP 5 provides a number of interesting ways to reuse your code so you can let the boring stuff take care of itself. This eight-part series will show you how to create helpers to take care of repetitive tasks and free up your precious coding time for the real challenges.

    When it comes to speeding up the development of web applications, experienced PHP programmers tend to be rather lazy, and I'm not using that adjective with a negative connotation. Popular concepts like "don't reinvent the wheel" and DRY (short for "don't repeat yourself") help developers avoid creating PHP programs from scratch, while maintaining a high level of control over how their logic is implemented.

    Naturally, as you may have guessed, the most direct and simplest application of these concepts is code reuse. This concept can be applied through a variety of custom and third-party libraries, packaged in the form of classes or functions, or a combination of both.

    Undoubtedly, the ultimate implementation of code reuse is a full-featured framework. Such frameworks provide developers with a set of well-trusted classes, modules, plug-ins and helpers that permit them to build complex web-based programs very quickly and without suffering premature hair loss.

    But, wait a minute! If you reread the previous sentence, you'll notice that I subtly introduced the term "helpers." What are they? Well, if you still haven't coded one on your own, helpers are usually small blocks of reusable code that help programmers to perform certain repetitive tasks.

    A helper usually can be structured as one single class or as a set of functions, and the things it does generally aren't as complex as those done by a full-blown library. Common tasks that must be performed over and over again with different projects, such as building portions of a URL, generating web site breadcrumbs and formatting chunks of text, are typical functions of helpers, to cite just a few illustrative examples.

    Despite its seeming simplicity, building helpers can be a pretty challenging process, particularly for beginners whom are just starting to implement the object-oriented paradigm in PHP 5. So, in this series of articles, I'm going to introduce you as gently as possible to creating different types of helpers, which hopefully will make you understand the basis of this process and encourage you to create your own.

    Now, it's time to get rid of the boring theory and start learning how to build helpers with PHP 5. Let's begin right away!



     
     
    >>> 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 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek