Forum : What is Return values in PHP Functions and why is it used?
Brief description  about Online courses   join in Online courses
View Balu  Prasad 's Profile

What is Return values in PHP Functions and why is it used?

What is Return values in PHP Functions and why is it used????
Asked by Balu Prasad | Mar 17, 2010 |  Reply now
Replies (1)
View teacher siliconindia 's Profile
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
Mar 17, 2010