Realizable type constraints in class methods and functions of PHP
This article mainly explains the "PHP class methods and functions in the realizable type constraints", the article explains the content is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in-depth, together to study and learn "PHP class methods and functions in the realizable type constraints" bar!
Type constraints can be implemented in class methods and functions of PHP, but parameters can only specify four types: class, array, interface and callable. Parameters can default to NULL,PHP and cannot constrain scalar types or other types.
The following is an example:
The copy code is as follows: