Join David Powers for an in-depth discussion in this video Using the exercise files, part of Strict Data Types in PHP.
- View Offline
- [Voiceover] If you're a subscriber to the lynda.com online training library, you have access to the exercise files for this course. Just download them from the link on the course's page, and unzip them to a convenient location. I've got them here on my desktop. Let's take a quick look at them. The files are organized in folders corresponding to each chapter, and inside each chapter folder, there's a separate folder for each video that uses exercise files. If we take a look at one of these folders, in there are the files for each video, and if the file is in a different state, at the end of the video, it has _end appended to the file name.
Because we're working with PHP, you'll need to copy the exercise files into your server root. I'm using a local testing server so I copied them into a folder called Data Types in my server's htdocs folder. That's basically all you need to know about the exercise files. So let's get on with our exploration of strict data types in PHP.
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