PHP
  Home arrow PHP arrow Using Method Call Overloading in PHP 4
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 Method Call Overloading in PHP 4
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 6
    2006-07-18


    Table of Contents:
  • Using Method Call Overloading in PHP 4
  • Going backwards: a quick look at a previous example
  • Overloading multiple property accesses: combining the “__set()” and “__get()” methods in a single class
  • Triggering the “__call()” method in the background: overloading a method call

  • 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 Method Call Overloading in PHP 4
    ( Page 1 of 4 )

    This is part two of the series “Overloading classes in PHP.” In three tutorials, this series teaches how to overload your classes in PHP 4 by using the “overload()” PHP built-in function, in conjunction with the implementation of the “__set()”, “__get()” and “__call()” methods, and explores the native support of object overloading in PHP 5.

    Introduction

    As usual, I’d like to refresh the topics that I covered in the first part of this series, regarding the overloading of classes in PHP 4, so it will be much easier to come back to the subject and continue exploring its most relevant aspects. Stepping back to the previous tutorial, you’ll certainly remember that I went through the key points of overloading classes in PHP, and paid close attention to explaining the implementation of the “__set()” and “__get()” methods, which can be called automatically, after a given class has been overloaded.

    Particularly, I showed you how to trigger the methods by overloading several property accesses. This can be quite useful, particularly if you want to run custom code without the need to explicitly call these methods. As you learned before, after a class has been overloaded by the “overload()” function, the PHP 4 interpreter will enable this functionality, which can be used in different clever ways.

    All right, after refreshing the concepts that I covered in the previous tutorial, it’s time to focus on the current one. In this second article, I’ll first show you how to combine the two “__set()” and “__get()” methods into one single class, so they can be properly triggered when overloading a property access. Then I’ll teach you how to overload a method call, in order to trigger the homonymous “__call()” method.

    After defining the topics to be covered in this second article, let’s move on and continue exploring the different approaches for overloading classes in PHP 4. It’s going to be really instructive!



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

       

    PHP ARTICLES

    - 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...
    - Mastering WHILE Loops for PHP and MySQL





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