Welcome to my series on every PHP keyword and its usage. Today’s item:
This keyword can only be used as a type hint or return type, and indicates that it only accepts or returns a value of the following form:
- A closure / anonymous function
- A string with the name of an existing function
- An array containing an object as its first value and the name of a method as its second value
- An array containing the name of a class as its first value and the name of a static method as its second value
callable can be run by adding arguments inside brackets to the variable name, e.g.
Author Callum Muir