Chapter 12. Functions

Table of Contents
User-defined functions
Returning values
Function arguments
old_function

User-defined functions

A function may be defined using syntax such as the following:

function foo ($arg_1, $arg_2, ..., $arg_n) {
    echo "Example function.\n";
    return $retval;
}
      

Any valid PHP code may appear inside a function, even other functions and class definitions.

Functions must be defined before they are referenced.