Join David Powers for an in-depth discussion in this video What you should know before watching this course, part of PHP: Strict Data Types.
- [Voiceover] Let's take a quick look to see what you need to know to follow this course, starting with the target audience. The course is primarily aimed at PHP developers, but it should also be of interest to programmers in other languages who want to understand how strict data typing has been implemented in PHP. If you fall into that category, some basic knowledge of PHP syntax would be useful, but it's not essential. However, I do expect viewers to know what I'm talking about when I refer to objects and interfaces.
If you are a PHP developer, you should have a solid understanding of writing PHP scripts, including using objects, builtin classes and some common builtin functions. If you want to run the example files that accompany this course, for Chapter One and the first video in Chapter Two, you'll need a web server running PHP 5.4 or later. For the rest of the course, you need PHP 7. If you have PHP 7 installed, there's no need to install PHP 5, as well.
All the examples run on PHP 7.
First, he introduces the basics of type juggling and type casting in PHP. Then, he reviews strict typing with objects, arrays, and callback functions, which were introduced in PHP 5. He also reviews scalar type hints in PHP 7, which can have unexpected side effects for unwary developers. David concludes with a frank assessment of the practicalities of strict typing, and a simple recommendation that will help most developers use the new feature: define in strict and execute in weak.
- Implicit and explicit type casting
- Using strict data types
- Declaring return types in PHP 7
- Creating scalar parameter declarations and scalar return type declarations
- Assessing the merits of strict data types