© Mikael Olsson 2021
M. OlssonPHP 8 Quick Scripting Referencehttps://doi.org/10.1007/978-1-4842-6619-9_18

18. Type Declarations

Mikael Olsson1  
(1)
Hammarland, Finland
 

Type declarations allow the type to be specified for properties, function parameters, and function return types. This permits the PHP engine to enforce that the specified types are used.

Argument Type Declarations

Early versions of PHP relied exclusively on proper documentation of functions for developers to know what arguments a function accepts. To allow for functions that are more robust, PHP 5 began to introduce argument type declarations, permitting the type of a function parameter to be specified. Valid types for type declarations are shown in Table 18-1, along with the PHP version ...

Get PHP 8 Quick Scripting Reference: A Pocket Guide to PHP Web Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.