Php program to execute return statement using function

Php program to execute return statement using function. Using this program we can print the return statement using the function. The return statement in PHP 7 now supports Type Declarations. Enabling the strict requirement, as with the type declaration for function arguments, will result in a “Fatal Error” if a type mismatch occurs. When declaring the function, add a colon ( : ) and the type right before the opening curly ( )bracket to declare a type for the function return.

<?php declare(strict_types=1); 
function addNumbers(float $a, float $b) : float
{
return $a + $b;
}
echo addNumbers(5,3.6);
?>

 

Output:

8.6