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  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
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

Overloading Classes in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 4
    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:
      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


    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


       · Over this last part of the series, you'll learn how to overload classes in PHP 5....
     

       

    PHP ARTICLES

    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...
    - Working with the Email Class in Code Igniter
    - Building Your Own System Tray Application Us...
    - Structuring Your Projects for Web Applicatio...
    - Inserting, Updating and Deleting Database Ro...
    - Building Your Own Desktop Notepad Applicatio...
    - Web Application Security Overview
    - Working with the Active Record Class in Code...
    - Generate PDF Documents with PHP on the Windo...
    - Sending Email with PHP Networking
    - Performing Strict Validation with the Code I...
    - The preg_replace_callback() function in PHP
    - PHP Networking
    - Validating Web Forms with the Code Igniter P...





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