Php program to print the float value using function

A Php program to print the float value using function. In this program we can print the Php program to print the float value using function. A function is defined as a relationship between a set of inputs and a set of possible outputs, with each input relating to exactly one outcome. The function notation f:XY can be used to denote the statement that f is a function from X to Y.

<?php declare(strict_types=1); 
function addNumbers(float $a, float $b) : float

{
return $a + $b;
}
echo addNumbers(4.6, 5.2);
?>

 

Output:

9.8

What is declare in php

The declare keyword gives a block of code an execution directive. The directive applies to the rest of the code in the file if the declare statement is not followed by a block. Ticks, encoding, and strict types are the three directives that can be declared.

What is function in php language

Other programming languages’ functions are similar to PHP’s. A function is a piece of code that takes another input in the form of a parameter, processes it, and then returns a value. Although they are built-in functions, PHP also allows you to create your own.

What are the types of php function

In PHP, there are several different types of functions. Internal (built-in) Functions and External (external) Functions are the two types of functions. Functions that are defined by the user.