How to declare a function?
Answer
•function name($param) { return $result; }.
•Default values: function f($x = 10).
•Type hints: function f(int $x): string.
•Anonymous: $fn = function() {}.
•Arrow functions: fn($x) => $x * 2.
Was this answer helpful?