PHP
  Home arrow PHP arrow Implementing Property Overloading in P...
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

Implementing Property Overloading in PHP 4
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 6
    2006-07-11

    Table of Contents:
  • Implementing Property Overloading in PHP 4
  • Overloading a property access: using the “__set()” method
  • Overloading a PHP 4 class: using the native “overload()” function
  • Going deeper into property access overloading: using the “__get()” 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


    Implementing Property Overloading in PHP 4


    (Page 1 of 4 )

    The object-oriented paradigm includes the ability to overload classes; not surprisingly, this is possible in PHP. In this first part of a series, you will learn how to implement class overloading in PHP 4, specifically using the “overload()” function, which comes in handy for triggering “__set()” and “__get()” methods when a property access is overloaded.

    Introduction

    If you’ve been working with object-oriented programming in PHP for a considerable time, you probably have a decent grounding in building up classes, defining their methods and properties, as well as implementing several types of object interaction, including aggregation and composition in cases where these techniques are applicable. Additionally, you’ll surely have started using some of the most important foundations of object-based development, such as inheritance and polymorphism.

    To return to mastering all the concepts that I deployed before, perhaps you consider yourself an experienced PHP developer that has explored and understood the nitty-gritty of working with objects during the development of different applications. However, luckily for you and me, the object-oriented paradigm always has some additional exciting aspects that might be pretty interesting to expand our overall knowledge of PHP.

    That’s precisely the case with the overloading of classes, since PHP comes with a fairly handy support for overloading both method calls and property access of objects, something that can be truly useful when used in a clever way. Certainly, I don't mean that the implementation of class overloading in PHP is as powerful as you’ll find if you work with C++ or Python, but it definitely can help in the development of more robust code, particularly when you want to combine it with the advantages offered by inheritance.

    After introducing the topic, allow me to tell you what you’ll learn during the course of this series, so you won’t suffer the effects of unexpected surprises. In these articles, I’ll explain the basics of class overloading, starting with the application of the “overload()” function in PHP 4, in conjunction with using the “_set()”, __get()” and “__call()” methods, accompanied of several practical examples, so you’ll have a clear idea of how to overload your classes. Also, I’ll cover class overloading in PHP 5, which offers native support for overloading methods and properties through the built-in methods that I mentioned before.

    With the preliminaries out of our way, let’s start learning more about how to implement class overloading in PHP. Let’s go!

    More PHP Articles
    More By Alejandro Gervasio


       · One of the most uncovered aspects of PHP is precisely the overloading of methods and...
       · The __get, __set and __call methods must return a boolean value that tell php...
       · Thank you for commenting on my PHP article. Also, I thank you for the useful...
     

       

    PHP ARTICLES

    - 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
    - Handling Attachments in MIME Email with PHP
    - Completing the Project Management Application
    - Sending MIME Email with PHP
    - Handling Files for a Project Management Appl...
    - Viewing and Editing Tasks for a Project Mana...





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