soma(5, 5); # Parâmetros default function login($user = "******", $password = "******") { echo "<br>User = {$user}"; echo "<br>Password = {$password}"; } login(); # Lista de Parâmetros # func_get_arg function subtrai() { $total = func_get_arg(0) - func_get_arg(1); echo "<br> {$total}"; } subtrai(5, 10); # func_get_args & func_num_args function somaTudo() { $lista = func_get_args(); $qntd = func_num_args(); $total = 0; // 1 método //for ($i = 0; $i < $qntd; $i++) { // $total += $lista[$i]; //} // 2 método foreach ($lista as $item) { $total += $item; } echo "<br> {$total}";
<?php print '<br>'; print subtrai(10, 2); function subtrai($num1, $num2) { return $num1 / $num2; }