PHP·98 questions

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?

More questions in this topic

Related questions from other topics