PHP Functions |
Similar to other programming languages, PHP provides a way for programmers to define functions, which can then be called elsewhere in the program. The syntax for a function is:
function "function_name" (arg1, arg2...)
{
[code to execute]
return [final_result];
}
where [final_result] is typically the variable holding the final value to be returned from the function.
Let's take a look at an example:
function double_this_number($input_number)
|
Elsewhere in the PHP code, we have
$x = 10;
|
The output will be
20 |