Logo


PHP Function Return Values



Return Values of Function

Using return statement, a function can return value or values.

Example:1

<?php
function add($a$b)
{
$total=$a+$b;
return 
$total;
}
echo 
add(7,7);
?>

Output

14

Example:2


<?php
function test($str)
{
return 
explode ("\n"$str);
}

$str "I\n am\n responsible\n for\n my\n own\n health.";
$parts=test($str);
print_r($parts);
?>

Output




If you like this Article, Share and Enjoy



See Also
Functions
Parameters in Functions