Miscellaneous

  Home arrow Miscellaneous arrow Advanced OOP Features
MISCELLANEOUS

Advanced OOP Features
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2010-05-26

    Table of Contents:
  • Advanced OOP Features
  • Object Cloning
  • Inheritance
  • Class Inheritance

  •  
     

    SEARCH CODEWALKERS

    Advanced OOP Features


    (Page 1 of 4 )

    The previous three-part article series introduced you to the fundamentals of object-oriented programming with PHP. This three-part series takes a look at the advanced OOP features offered by PHP 5. It is excerpted from chapter 7 of the book Beginning PHP and PostgreSQL 8: From Novice to Professional, written by W. Jason Gilmore and Robert H. Treat (Apress; ISBN: 1590595475).

    Chapter 6 introduced the fundamentals of object-oriented PHP programming. This chapter builds on that foundation by introducing several of the more advanced OOP features that you should consider once you have mastered the basics. Specifically, this chapter introduces the following five features:

    1. Object cloning: One of the major improvements to PHP’s OOP model in version 5 is the treatment of all objects as references rather than values. However, how do you go about creating a copy of an object if all objects are treated as references? By cloning the object, a feature that is new in PHP 5. 
       
    2. Inheritance: As mentioned in Chapter 6, the ability to build class hierarchies through inheritance is a key concept of OOP. This chapter introduces PHP 5’s inheritance features and syntax, and includes several examples that demonstrate this key OOP feature. 
       
    3. Interfaces: An interface is a collection of unimplemented method definitions and constants that serves as a class blueprint of sorts. Interfaces define exactly what can be done with the class, without getting bogged down in implementation-specific details. This chapter introduces PHP 5’s interface support and offers several examples demonstrating this powerful OOP feature. 
       
    4. Abstract classes: An abstract class is essentially a class that cannot be instantiated. Abstract classes are intended to be inherited by a class that can be instantiated, better known as a concrete class. Abstract classes can be fully implemented, partially implemented, or not implemented at all. This chapter presents general concepts surrounding abstract classes, coupled with an introduction to PHP 5’s class abstraction capabilities. 
       
    5. Reflection: As you learned in Chapter 6, hiding the application’s gruesome details behind a friendly interface (encapsulation) is one of the main OOP tenants. However, programmers nonetheless require a convenient means for investigating a class’s behavior. A concept known as reflection provides that capability, as described in this chapter.

    Advanced OOP Features Not Supported by PHP

    If you have experience in other object-oriented languages, you might be scratching your head over why the previous list of features doesn’t include one or more particular OOP features that you are familiar with from other languages. The reason might well be that PHP doesn’t support those features. To save you from further head scratching, the following list enumerates the advanced OOP features that are not supported by PHP and thus are not covered in this chapter:

    1. Namespaces: Although originally planned as a PHP 5 feature, inclusion of namespace support was soon removed. It isn’t clear whether namespace support will be integrated into a future version. 
       
    2. Method overloading: The ability to implement polymorphism through functional overloading is not supported by PHP and, according to a discussion on the Zend Web site, probably never will be. Learn more about why athttp://www.zend.com/php/ ask_experts.php
       
    3. Operator overloading: The ability to assign additional meanings to operators based upon the type of data you’re attempting to modify did not make the cut this time around. According to the aforementioned Zend Web site discussion, it is unlikely that this feature will ever be implemented. 
       
    4. Multiple inheritance: PHP does not support multiple inheritance. Implementation of multiple interfaces is supported, however.

    Only time will tell whether any or all of these features will be supported in future versions of PHP.

    More Miscellaneous Articles
    More By Apress Publishing

    blog comments powered by Disqus

    MISCELLANEOUS ARTICLES

    - Attention: Forum and Site Maintenance
    - Oracle Database XE: Indexes and Sequences
    - Modifying Tables in Oracle Database XE
    - Oracle Database XE: Tables and Constraints
    - More on Oracle Databases and Datatypes
    - Oracle Database XE Datatypes: Datetime and L...
    - Oracle Database XE Datatypes: Character and ...
    - From Databases to Datatypes
    - Firefox 3.6.6 Released with Improved Plug-in...
    - Attention Bloggers: WordPress 3.0 Now Releas...
    - Reflection in PHP 5
    - Inheritance and Other Advanced OOP Features
    - Advanced OOP Features
    - Linux from Scratch V.6.6 Review
    - Linux Gaining in Strength

    Developer Shed Affiliates

     



    © 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap