Please leave a comment If you found BROKEN LINK OK, thanks for visit my website,...!!!

Shooter Game Chrome PC Free Download Shooter Game Angels Fall First: Planetstorm PC Download Harvest Moon - Back To Nature PC Game Download Download PC Game TMNT 2 : Battle Nexus RIP MediaFire Prince Of Persia Warrior Within Download PC Game Resident Evil 2 img 1 metal slug super vehicle Devil May Cry 3 Portable Cool Game Download

Search


PHP Functions - Returning Values | Lombok Study

Besides being able to pass functions information, you can also have them return a value. However, a function can only return one thing, although that thing can be any integer, float, array, string, etc. that you choose!
How does it return a value though? Well, when the function is used and finishes executing, it sort of changes from being a function name into being a value. To capture this value you can set a variable equal to the function. Something like:
   * $myVar = somefunction();
Let's demonstrate this returning of a value by using a simple function that returns the sum of two integers.

PHP Code:

<?php
function mySum($numX, $numY){
$total = $numX + $numY;
return $total;
}
$myNumber = 0;
echo "Before the function, myNumber = ". $myNumber ."<br />";
$myNumber = mySum(3, 4); // Store the result of mySum in $myNumber
echo "After the function, myNumber = " . $myNumber ."<br />";
?>

Display:
Before the function, myNumber = 0
After the function, myNumber = 7

When we first print out the value of $myNumber it is still set to the original value of 0. However, when we set $myNumber equal to the function mySum, $myNumber is set equal to mySum's result. In this case, the result was 3 + 4 = 7, which was successfully stored into $myNumber and displayed in the second echo statement!

Related Post

1 komentar:

Brother would ask where the download php language id.zip?? I've been looking but have not been met .... please help brother ... please love comments on my blog .......
http://distrosantri.co.cc

Posting Komentar