Define and call
The function keyword begins a named function declaration. Parentheses contain its parameters; braces contain the body. Calling the function supplies argument values for those parameters.
Return a result
return sends a value to the caller and finishes the call. Save that result in a variable, pass it to another function or print it with echo. Printing and returning serve different purposes.
Keep the contract clear
Parameter and return type declarations describe the values a function accepts and returns. Type coercion and strict typing have further rules; the official manual explains them in detail.
Tested examples
function area(int $width, int $height): int { return $width * $height; } echo area(3, 4);12