PHP
  Home arrow PHP arrow PHP 5 Helpers: Calling Methods Out of Object Scope
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 
iPad news and developer info.
Ads by affinity 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
VPS Hosting 
Forums Sitemap 
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

PHP 5 Helpers: Calling Methods Out of Object Scope


By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 2
    2009-07-27


    Table of Contents:
  • PHP 5 Helpers: Calling Methods Out of Object Scope
  • Review: building a text helper class
  • Working with static methods
  • The new 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


    Summary: Theoretically defining the role of helper classes in PHP 5 (and other popular server-side scripting languages) is a pretty approachable process. As their name suggests, helper classes provide developers with a set of logically-grouped methods that allow them to easily perform certain repetitive tasks that are common to different web applications. This is the second part of an eight-part article series that shows you how to build a variety of useful helper classes and expand on their functionality.

    PHP 5 Helpers: Calling Methods Out of Object Scope
    (Page 1 of 4 )

    Typical examples of helper classes are those that dynamically build portions of a URL and validate incoming data, or that apply specific text-formatting filters to a supplied string before doing something useful with it, such as inserting it into a database table. Feel free to add your own to the list.

    While everything looks good in theory when it comes to defining what a helper class is, things can get more complex when putting this definition into practice. This is especially true for inexperienced PHP programmers just starting to use the object-oriented paradigm for building web-based programs.

    So, if you need to expand your existing skills as a PHP developer and wish to learn how to build helper classes with PHP 5 by means of a true hands-on approach, then begin reading this series of articles right now!

    In the first part of this series, I offered a gentle introduction to creating a text helper class. This class was tasked with applying some basic filters to an inputted string. If you've already read that article, then it’s quite probable that you have a clear idea of how to build this kind of class in a relatively easy manner.

    The methods of the class that I just mentioned were declared implicitly dynamic, even though it’s perfectly possible to call them statically, and the PHP engine won’t raise any errors about this process. However, it would be much better to declare these methods explicitly static, thus taking advantage of the functionality offered by the text helper class without having to spawn an instance of it.

    Therefore, in this second part of the series I’m going to use a decent variety of code samples to explain how to improve the use of the text helper class developed before by turning its regular methods into static ones.

    Want to see how this will be accomplished in a few basic steps? Then go ahead and start reading right away!



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

       

    PHP ARTICLES

    - PHP Excel Customizations: Working with Formu...
    - MVC and the Zend Framework
    - PHP: Rendering Web Pages Using the Composite...
    - PHP: Creating Dynamic Web Pages with the Com...
    - Secure Encrypting and Decrypting for Your PH...
    - PHP: Creating Single View Objects with the C...
    - PHP: View Object Collections and the Composi...
    - Securing Your PHP Website
    - Determine Link Relevance and Unique Class C ...
    - PHP Composite View Design Pattern: Introduci...
    - Facebook PHP API Applications: A Second Look
    - Secure PHP Programming
    - Facebook PHP API Applications: Basic Introdu...
    - SOAP Servers and Web Services
    - Using XPath, SOAP, and More with Web Services


    Code Analysis Tools
    Enterprise code analysis tools that deliver quality and reliable code

     


     


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