Php program to print the addition of two numbers

A Php program to print the addition of two numbers. Using this program we can print the addition of two numbers using function. 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 these are built-in functions, PHP also allows you to construct your own.

function num(int $a, int $b)
return $a + $b;
echo num(1, "1");
return num




What is return statement in php

Returns control of the program¬†to the calling module. Following the invocation of the called module, execution restarts at the expression. When called from within a function, the return statement terminates the current function’s execution and returns its argument as the function call’s value.

The intended data types of the result that a function or a class method should return are specified in the return type declaration. PHP, for example, can convert the integer result into a string before returning the function result because of the return type declaration.

Using the return statement with a value or object, a function can return a value. Return signals the conclusion of the function’s execution and returns the value to the calling code. No, a function cannot have two returns; the first return will terminate the function, requiring you to build an object.