Tools, FAQ, Tutorials:
Returning a Value from a Function in PHP
How To Return a Value Back to the Function Caller? in PHP?
✍: FYIcenter.com
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
⇒ Passing an Argument to a Function in PHP
⇐ Invoking a User Function in PHP
2016-12-24, ∼2177🔥, 0💬
Popular Posts:
Where to get the detailed description of the json_encode() Function in PHP? Here is the detailed des...
How To Copy Array Values to a List of Variables in PHP? If you want copy all values of an array to a...
How to view API details on the Publisher Dashboard of an Azure API Management Service? You can follo...
How To Convert a Character to an ASCII Value? If you want to convert characters to ASCII values, you...
How to search for the first match of a regular expression using re.search()? The re.search() functio...