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  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
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? 
PHP

Using Method Call Overloading in PHP 4
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 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:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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


       · Over this second part of the series, you'll learn how to overload classes by using...
       · The __call method should return a boolean value letting php know whether or not you...
       · Thank you for your useful comments regarding the implementation of the __call()...
     

       

    PHP ARTICLES

    - Validating Web Forms with the Code Igniter P...
    - Output Buffering
    - Paginating Database Records with the Code Ig...
    - HTTP Headers in Web Development
    - Project Management: Administration
    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway