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, 1540🔥, 0💬
Popular Posts:
How to start Docker Daemon, "dockerd", on CentOS systems? If you have installed Docker on your CentO...
How To Get the Minimum or Maximum Value of an Array in PHP? If you want to get the minimum or maximu...
How To Set session.gc_divisor Properly in PHP? As you know that session.gc_divisor is the frequency ...
How to use the XML to JSON Conversion Tool at freeformatter.com? If you want to try the XML to JSON ...
Can You Add Values to an Array without Keys in PHP? Can You Add Values to an Array with a Key? The a...