Functions¶
Functions are defined with a set of parameters, a body of code for processing, and a returned value, typed or not.
Methods are defined almost the same way, except for some more options and within the context of a class.
A function is said anonymous when it has no name. This is the case of the closures and the arrow functions.
<?php
function foo($a, $b) {
return $a - $b;
}
?>
See also PHP Functions and How To Use Functions in PHP.
Related : Recursion, Closure, Arrow Functions, Method, Anonymous Function, First Class Callable, Default Parameter, Dereferencing, Disable Functions, Return, Variable Arguments, Callbacks, Fallback Function, Fallback To Global, Pure Function, Call Graph, Impure Function, Parameter Removal, Undefined, Dynamic Class Constant, Naming Conflict, PHP Native Function, Relay Function, Custom Function, Identity