Chapter Review:

• What is inheritance? How do you implement inheritance in PHP code? (See page 152.)

Inheritance is the OOP concept that allows "child" classes to inherit methods and attributes from "parents". This is accomplished throught the syntax:

ChildClassnmae extends ParentClassname {}.

• What is polymorphism? (See page 151.)

Polymorphism is one of top candidates for words that make you sound really smart (despite...). It also describes the OOP concept of overriding parent class methods where different object types can have different results.

• What does it mean to override a method? How do you do that? (See page 161.)

Define the same method in a child class - with the same number of parameters.

• What is access control or visibility? What are the three levels of visibility and what do they mean? (See page 165.)

Access control defines the visibility of class members inside and outside the class. Public is accessible on any page the class is called. Protected is available to inherited classes. Private is only available in the class declared.

• What is the scope resolution operator? What are some of its uses? (See page 172.)

The scope resolution operator is two colons ::. It has a curious Israeli name of Paamayim Nekudotayim. The most simple application (and the one I'll be using for now), is to refer to static, constant or over-ridden members of a class.

• What is a static class attribute? How do you reference a static class attribute within a class? What is a static class method? How do you invoke a static class method? (See pages 176 and 177.)

Static class attributes will retain their value within the class and can be accesse via the className::staticAttributename syntax. You can reference within a class using the self:: operator.

Toggle Sidebar