Home arrow PHP arrow Using Method Call Overloading in PHP 4

Using Method Call Overloading in PHP 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.

TABLE OF CONTENTS:
  1. Using Method Call Overloading in PHP 4
  2. Going backwards: a quick look at a previous example
  3. Overloading multiple property accesses: combining the “__set()” and “__get()” methods in a single class
  4. Triggering the “__call()” method in the background: overloading a method call
By: Alejandro Gervasio
Rating: starstarstarstarstar / 6
July 18, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

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
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: