What is Return values in PHP Functions and why is it used?
By Balu Prasad
What is Return values in PHP Functions and why is it used????
Teacher SiliconIndia replied to Balu Prasad Wednesday, March 17, 2010
Hi Balu,
To let a function return a value, use the return statement.
Example
<html>
<body>
<?php
function add($x,$y)
{
$total=$x+$y;
return $total;
}
echo "1 + 16 = " . add(1,16);
?>
</body>
</html>
Output:
1 + 16 = 17