Dynamic Arguments in PHP Function

<?php 

function add()
{
    $params = func_get_args();
    $sum = 0;
    foreach($params as $param) {
        $sum += $param;
    }
    return $sum;
}

echo 'sum 1: '.add(1, 2);
echo '<br>sum 2: '.add(6, 8, 30);
echo '<br>sum 3: '.add(14, 7, -3, 9, -20);

?>       
    
sum 1: 3
sum 2: 44
sum 3: 7