SyntaxStudy
Sign Up
Home PHP Exercises PHP Functions

PHP Functions

Beginner

Complete the PHP function declarations.

To declare a function: add($a, $b) { return $a + $b; }

To specify a return type: function add(int $a, int $b): { ... }

To give a parameter a default value: function greet(string $name = ) { ... }

An anonymous function: $fn = ($x) { return $x * 2; };