Chapter 12. Functions
Table of Contents
User-defined functions
Function arguments
Returning values
Variable functions
Internal (built-in) functions
User-defined functions
A function may be defined using syntax such as the following:
Example 12-1. Pseudo code to demonstrate function uses
<?php
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.
In PHP 3, functions must be defined before they are referenced.
No such requirement exists in PHP 4. Except when a function
is conditionally defined such as shown in the two examples
below.
When a function is defined in a conditional manner such
as the two examples shown. Its definition must be processed
prior to being called.
|