OOP

Zend PHP 7 Certification – OOP – Type Hinting

This post covers the Type Hinting section of the OOP chapter when studying for the Zend PHP 7 Certification.
Type declarations, or type hints as they were previously known, are used to specify the expected data type of an argument in a function declaration.
Prior to PHP 7, you could use the following types.

Zend PHP 7 Certification – OOP – Magic Methods

This post covers the Magic Methods section of the OOP chapter when studying for the Zend PHP 7 Certification.
Magic methods in PHP are methods that allow you to react to certain events when using objects. They are usually prefixed with a double underscore, __.
Some of the methods are what PHP defines as ‘magical’ …

Zend PHP 7 Certification – OOP – Class Constants

This post covers the Class Constants section of the OOP chapter when studying for the Zend PHP 7 Certification.
Class constants are constant values on a per-class basis that remain the same and are unchangeable.
Constants differ from normal variables in that you don’t use the $ symbol to declare or use them.
They …

Zend PHP 7 Certification – OOP – Reflection

This post covers the Reflection section of the OOP chapter when studying for the Zend PHP 7 Certification.
Reflection in PHP is a feature that allows for the introspection of:

Objects
Classes
Methods
Properties
Functions
Parameters
Exceptions
Extensions

Reflection classes are used to report information about a class r an interface, and can …

Zend PHP 7 Certification – OOP – SPL

This post covers the SPL section of the OOP chapter when studying for the Zend PHP 7 Certification.
SPL, or Standard PHP Library, is a collection of interfaces and classes that are meant to solve common problems without having to install any external libraries. The library is available and compiled by default in PHP 5.

Zend PHP 7 Certification – OOP – Late Static Binding

This post covers the Late Static Binding section of the OOP chapter when studying for the Zend PHP 7 Certification.
Late static binding is a feature introduced in PHP 5.3 that can be used to reference the called class in a context of static inheritance.
Whenever keywords such as self or __CLASS__ are used, they …

Zend PHP 7 Certification – OOP – Traits

This post covers the Traits section of the OOP chapter when studying for the Zend PHP 7 Certification.
Traits, introduced in PHP 5.4.0, are a mechanism for code reuse and are intended to reduce some limitations of single inheritance by enabling a developer to reuse sets of methods freely in several independent classes living in …

Zend PHP 7 Certification – OOP – Autoload

This post covers the Autoload section of the OOP chapter when studying for the Zend PHP 7 Certification.
In order to use a class within PHP, the class must be included by using include or require. With multiple classes, one of the biggest annoyances is having to write a long list of needed includes, one …

Zend PHP 7 Certification – OOP – Static Methods and Properties

This post covers the Static Methods and Properties section of the OOP chapter when studying for the Zend PHP 7 Certification.
Declaring class properties or methods as static, using the static keyword, makes them accessible without needing an instantiation of the class.
A property declared as static cannot be accessed with an instantiated class …

Zend PHP 7 Certification – OOP – Exceptions

This post covers the Exceptions section of the OOP chapter when studying for the Zend PHP 7 Certification.
An exception can be thrown and caught within PHP like many other programming languages. In PHP, the throw keyword is used to throw an exception.
When wrapping code within a try block, the catch part of the …