PHP
  Home arrow PHP arrow Implementing Property Overloading in PHP 4
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? 
Google.com  
PHP

Implementing Property Overloading in PHP 4
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 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:
      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


    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
     

       

    PHP ARTICLES

    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek