PHP theorytheory 0/50 · 0%
Fundamentals · easy

8. Functions

Reusable blocks of logic.

Functions are declared with the function keyword and can accept default parameter values, variadic arguments (...$args), and typed parameters/return types. Named arguments (PHP 8) let callers specify parameters by name.

Functions can be passed as callables or wrapped in closures for higher-order use.

Check your understanding

  1. 1. How do you accept a variable number of arguments?

  2. 2. What is a named argument call example?