2.8. Functions
A function in PHP can be built-in or user-defined; however, they are both called the same way.
The general form of a function call is
func(arg1,arg2,...)
The number of arguments varies from one function to another. Each argument can be any valid expression, including other function calls.
Here is a simple example of a predefined function:
$length = strlen("John");
strlen is a standard PHP function that returns the length of a string. Therefore, $length is assigned the length of the string "John": four.
Here's an example of a function call being used as a function argument:
$length = strlen(strlen("John"));
You probably already guessed the result of this example. First, the inner strlen("John") is executed, which results in ...
Get PHP 5 Power Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.