Strict Data Types in PHP is published by Lynda in April 2016. This book has 1h 10m pages in English, ISBN-13 .
One of the most important (and controversial) new features in PHP 7 is the option to use strict data types, in the form of parameter and return type declarations. Strict typing helps eliminate errors in more complex applications. Its use remains optional though, as many consider it a betrayal of the fundamental principles of a loosely typed language like PHP. In this course, David Powers explores the pros and cons of strict data types in PHP 5 and 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