1.

How To Return A Value Back To The Function Caller?

Answer»

You can return a VALUE to the function caller by USING the "return $value" statement. Execution control will be TRANSFERRED to the caller immediately after the return statement. If there are other statements in the function after the return statement, they will not be executed. Here is a PHP script example on how to return values:
<?php
function getYear() {
$year = DATE("Y");
return $year;
}
print("This year is: ".getYear()."\N");
?>
This script will print:
This year is: 2006

You can return a value to the function caller by using the "return $value" statement. Execution control will be transferred to the caller immediately after the return statement. If there are other statements in the function after the return statement, they will not be executed. Here is a PHP script example on how to return values:
<?php
function getYear() {
$year = date("Y");
return $year;
}
print("This year is: ".getYear()."\n");
?>
This script will print:
This year is: 2006



Discussion

No Comment Found