PHP Function Parameter

We have already seen the different type of the variable such as local variable and global variable

PHP Function Parameter Example :

Function parameters are declared after the function name and inside parentheses. They are declared much like a typical variable would be:

<!DOCTYPE html>


function add($value) {
    $value = $value + 5;
    return $value;

$result = add (10);
echo "Return value : $result";



Output :

Return value : 15

Explanation :

In the above example we have called the function using the following statement –

$result = add (10);

In this case we have called function add() and we have passed value 10 the function. While executing the function value 10 will be assigned to the function formal parameter variable i.e value.

function add($value)

The formal parameter that we have passed is then updated by the function and updated value will be returned to the line where function was called previously.

$result = add (10); // Returned value stored in result