When the execution reaches this function call operation, it will:
Evaluate all calling arguments to values or variable references.
Assign argument values and references to argument variables defined in the "function" statement.
Start to execute the first statement of the function body.
Continue to execute the function body until the end of the function body or a "return" statement.
If a "return" statement is reached with a value specified, that value is returned as this function call operation.
If a "return" statement is reached with a no value specified, NULL is returned as this function call operation.
If no "return" statement is reached, NULL is returned as this function call operation.
Here is a simple example script showing us how to use function call operations:
<?php # FunctionCallOperations.php
# Copyright (c) 2003 by Dr. Herong Yang. http://www.herongyang.com/
#
# Defining a function that returns a value
function f2c($fahrenheit) {
$celsius = ($fahrenheit - 32.0 ) / 1.8;
return $celsius;
}
# Defining a function that returns NULL
function showAnyFooter($author) {
print(" Copyright: $author\n");
print(" Last Modified: 2003\n");
}
print("\n Function call as a standalone expression:\n");
showAnyFooter("Herong Yang");
print("\n Function call as an operand of another operation:\n");
if (f2c(20.0)<0.0) print(" It's cold here!\n");
print("\n Function call as an argument of another call:\n");
print(" How is the temperature? ");
print(f2c(110.0));
?>
If you run this sample script, you should get:
Function call as a standalone expression:
Copyright: Herong Yang
Last Modified: 2003
Function call as an operand of another operation:
It's cold here!
Function call as an argument of another call:
How is the temperature? 43.3333333333