This is the power of polymorphism.
These three key OOP concepts, encapsulation, inheritance, and polymorphism,
are further introduced as they apply to PHP through this chapter and the next.
Key OOP Concepts
This section introduces key object-oriented implementation concepts, including
PHP-specific examples.
Classes
Our everyday environment consists of countless entities: plants, people, vehicles,
food...I could go on for hours just listing them. Each entity is defined by a particular set
of characteristics and behaviors that ultimately serves to define the entity for what it is.
For example, a vehicle might be defined as having characteristics such as color, number
of tires, make, model, and capacity, and having behaviors such as stop, go, turn, and
honk horn. In the vocabulary of OOP, such an embodiment of an entity??™s defining
attributes and behaviors is known as a class.
Classes are intended to represent those real-life items that you??™d like to manipulate
within an application. For example, if you want to create an application for managing
a public library, you??™d probably want to include classes representing books, magazines,
employees, special events, patrons, and anything else that would require oversight.
Each of these entities embodies a certain set of characteristics and behaviors, better
known in OOP as fields and methods, respectively, that define the entity as what it is.
Pages:
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247