Home arrow PHP arrow Overloading Classes in PHP 5

Overloading Classes in PHP 5

Welcome to the last installment of the series “Overloading classes in PHP.” Comprised of three tutorials, this series shows you how to overload your classes whether you’re using PHP 4 or PHP 5, and explains in detail the implementation of the “__set()”, “__get()” and “__call()” methods, in order to overload property accesses and method calls respectively.

TABLE OF CONTENTS:
  1. Overloading Classes in PHP 5
  2. Overloading a property access in PHP 5: calling the “__set()” method
  3. More about members overloading: triggering automatically the “__get()” method
  4. Overloading multiple member accesses: combining the “__set()” and “__get()” method in the same class
  5. Overloading a method call: triggering the “__call()” method
By: Alejandro Gervasio
Rating: starstarstarstarstar / 10
July 25, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

As you learned in the previous articles, after a class has been overloaded by the “overload()” function that comes with PHP 4, it’s possible to run custom code automatically by calling the set of methods that I mentioned right at the beginning of this tutorial. Whether you’re overloading a property access, in order to call the “__set()” and “__get()” methods, or using an overloaded method call, which obviously triggers the “__call()” method, PHP provides you with the ability to invoke these methods automatically and run specific code without having to write explicit method calls inside an application.

Also, it should be noticed that overloading classes in PHP 4 isn’t as powerful as in other object-oriented languages like C++ or Python, but as I hopefully demonstrated by the numerous hands-on examples I showed previously, PHP offers a fairly comprehensive set of methods for overloading classes in a simple way.

Now that you learned the pros and cons of overloading classes in PHP 4, it’s time to move on and continue exploring the subject, since there are still a few additional topics that need to be covered. So, what’s comes next now? All right, in this last part of the series, I’ll be explaining how to overload classes specifically in PHP 5, which offers native support for overloading class members and methods, without having to explicitly call the PHP built-in “overload()” function.

Are you ready to learn how to overload your PHP 5 classes? Right, let’s begin.



 
 
>>> 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: