PHP Function Return
In this chapter you will learn:
Description
Function can return one value back from functions by using the return statement.
Note
If you try to assign to a variable the return value of a function that has no return value, your variable will be set to NULL.
Example
Return value from a function
<?PHP//ja v a 2 s . com
function foo() {
print "In function";
return 1;
print "Leaving function...";
}
print foo();
?>
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- How to return a reference
- Syntax to return reference from a function
- Example - Return reference from a function
Home » PHP Tutorial » PHP Function Create