August 2003
Intermediate to advanced
1104 pages
19h 27m
English
When you declare a function, you start with the function statement. Next comes a name for your function. Inside the parentheses is a list of arguments separated by commas. You may choose to have no arguments. Figure 4.1 shows you the form of a function declaration.
In other languages, including older versions of PHP, you must declare a function above any call to it. This is not true of PHP 4. You may put a function declaration after calls made to it. When you call a function, you write its name followed by parentheses, even if there are no arguments to pass.
function function_name(arguments) { code block } |
Functions allow you to put together a block of code that you will repeat several ...