August 2013
Intermediate to advanced
140 pages
1h 49m
English
CHAPTER 18
![]()
Type Hinting
PHP relies on the proper documentation of functions for developers to know what arguments a function can take. To simplify this PHP 5 introduced type hinting, which allows a function to specify the type of arguments it accepts. Allowed types include classes, interfaces and the pseudo types array and callable.
| Name | Description |
|---|---|
| class name | Argument must be an object of this class or a child. |
| interface name | Argument must be an object implementing this interface. |
| array | Argument must be an array. |
| callable | Argument must be callable as a function. |
A type hint is set by prefixing the parameter with ...
Read now
Unlock full access