PHP
  Home arrow PHP arrow Overloading Classes in PHP 5
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? 
PHP

Overloading Classes in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 6
    2006-07-25


    Table of Contents:
  • Overloading Classes in PHP 5
  • Overloading a property access in PHP 5: calling the “__set()” method
  • More about members overloading: triggering automatically the “__get()” method
  • Overloading multiple member accesses: combining the “__set()” and “__get()” method in the same class
  • Overloading a method call: triggering the “__call()” method

  • 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


    Overloading Classes in PHP 5
    ( Page 1 of 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.

    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
     

       

    PHP ARTICLES

    - Using Directory Iterators to Build Loader Ap...
    - Using the spl_autoload() Functions to Build ...
    - Working Out of the Object Context to Build L...
    - Using the _autoload() Magic Function to Buil...
    - The Destruct Magic Function in PHP 5
    - The Autoload Magic Function in PHP 5
    - Developing a Recursive Loading Class for Loa...
    - The Sleep and Wakeup Magic Functions in PHP 5
    - Using the Clone Magic Function in PHP 5
    - Including Files Recursively with Loader Appl...
    - The Call Magic Function in PHP 5
    - Designing a Captcha System with PHP and MySQL
    - Using Static Methods to Build Loader Apps in...
    - The Isset and Unset Magic Functions in PHP 5
    - Advanced PHP Form Input Validation to Check ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT