Abstract
Chapter 6 introduced the fundamentals of object-oriented programming (OOP). This chapter builds on that foundation by introducing several of PHP’s more advanced OOP features. Specifically, this chapter introduces the following five features: Object cloning: One of the major improvements to PHP’s object-oriented 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. Inheritance: As discussed in Chapter 6, the ability to build class hierarchies through inheritance is a fundamental OOP concept. This chapter introduces PHP’s inheritance features and syntax, and it includes several examples that demonstrate this key OOP feature. Interfaces: An interface is a collection of unimplemented method definitions and constants that serves as a class blueprint. Interfaces define exactly what can be done with the class, without getting bogged down in implementation-specific details. This chapter introduces PHP’s interface support and offers several examples demonstrating this powerful OOP feature. Abstract classes: An abstract class is 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’s class abstraction capabilities. Namespaces: Namespaces help you to more effectively manage your code base by compartmentalizing various libraries and classes according to context. In this chapter I’ll introduce you to PHP 5.3’s new namespace feature.
Keywords
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Rights and permissions
Copyright information
© 2010 W. Jason Gilmore
About this chapter
Cite this chapter
(2010). Advanced OOP Features. In: Beginning PHP and MySQL. Apress. https://doi.org/10.1007/978-1-4302-3115-8_7
Download citation
DOI: https://doi.org/10.1007/978-1-4302-3115-8_7
Publisher Name: Apress
Print ISBN: 978-1-4302-3114-1
Online ISBN: 978-1-4302-3115-8
eBook Packages: Professional and Applied ComputingProfessional and Applied Computing (R0)Apress Access Books