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, ∼2442🔥, 0💬
Popular Posts:
How To Read the Entire File into a Single String in PHP? If you have a file, and you want to read th...
How To Pad an Array with the Same Value Multiple Times in PHP? If you want to add the same value mul...
How to use "json-to-xml" Azure API Policy Statement? The "json-to-xml" Policy Statement allows you t...
How to login to Azure API Management Publisher Dashboard? If you have given access permission to an ...
How To Create an Array with a Sequence of Integers or Characters in PHP? The quickest way to create ...