Variable Parameters of Functions in PHP
Let's consider the following code:
<?php
function func($num) {
echo $num * $num;
}
func(2);
?>
As you can see, when calling the function, the number 2
is passed into it.
It is not necessary to pass a number directly as a function parameter - you can also pass a variable containing the number we need:
<?php
function func($num) {
echo $num * $num;
}
$param = 2;
func($param);
?>
Create a function func that will take 3 numbers
as a parameter and output their sum. Using this function,
output the sum of the values of the following
variables:
<?php
$param1 = 1;
$param2 = 2;
$param3 = 3;
?>