4 Advanced Features

You have already seen how class type hinting and access control give you more control over a class’s interface. In this chapter I will delve deeper into PHP’s object-oriented features. This chapter will cover several subjects: Static methods and properties: Accessing data and functionality through classes rather than objects Abstract classes and interfaces: Separating design from implementation Traits: Sharing implementation between class hierarchies Error handling: Introducing exceptions Final classes and methods: Limiting inheritance Interceptor methods: Automating delegation Destructor methods: Cleaning up after your objects Cloning objects: Making object copies Resolving objects to strings: Creating a summary method Callbacks: Adding functionality to components with anonymous functions and classes Static Methods and Properties All of the examples in the previous chapter worked with objects....

July 17, 2024 · 37 min · Matt Zandstra

2 PHP and Objects

Objects were not always a key part of the PHP project. In fact, they were once described as an afterthought by PHP’s designers. As afterthoughts go, this one has proved remarkably resilient. In this chapter, I introduce this book’s coverage of objects by summarizing the development of PHP’s object-oriented features. We will look at the following: PHP/FI 2.0: PHP, but not as we know it. PHP 3: Objects make their first appearance....

July 17, 2024 · 12 min · Matt Zandstra

1 PHP: Design and Management

In July 2004, PHP 5.0 was released. This version introduced a suite of radical enhancements, notably improved support for object-oriented programming. This sparked significant interest in objects and design within the PHP community, continuing a trend that began with PHP 4, which first made object-oriented programming with PHP a serious reality. In this chapter, I examine some of the needs that coding with objects can address, briefly summarizing aspects of the evolution of patterns and related practices....

July 17, 2024 · 5 min · Matt Zandstra

Financial Analysis

Financial Analysis Using ratios to analyze performance—all while playing a game To help you develop financial intuitions, we’re going to play a little game. This game will introduce the world of finance by creating an understanding of how to use numbers to evaluate performance—the critical process of financial analysis. Financial analysis answers some of the most fundamental questions that financial professionals—from CFOs and managers to investors and bankers—need to answer, questions that go to the root of a company’s performance, viability, and potential....

July 17, 2024 · 65 min · Don

Object Basics

3. Object Basics Matt Zandstra (1) Brighton, UK Objects and classes lie at the heart of this book and, since the introduction of PHP 5 over a decade ago, they have been at the heart of PHP too. In this chapter, I establish the groundwork for more in-depth coverage of objects and design by examining PHP’s core object-oriented features. If you are new to object-oriented programming, you should read this chapter carefully....

July 16, 2024 · 56 min · Don