Functions

A function groups reusable code, declared with function. It receives parameters, optionally with a default value, and returns a result with return. Variable scope is local: a function does not see outer variables unless they are passed to it.

Example

function saluer(string $nom): string {
  return "Bonjour $nom";
}

Related concepts

The whole glossary