~/webbsrvprg/exercises/funktioner $ php ovn_fn3.php
Störst av 3 tal
Störst av 28, 33, 11
33
Störst av 55, 88, 178
178
Störst av 44, 44, 28
44
~/webbsrvprg/exercises/funktioner $
~/webbsrvprg/exercises/funktioner $ cat -n ovn_fn3.php
<?php
$title = "ovn_fn3.php";
include "../incl/header.php";
?>
<h1>Störst av 3 tal</h1>
<?php
function compareNum(int $tal1, int $tal2, int $tal3) {
if ($tal1 >= $tal2) {
if ($tal1 >= $tal3) {
return $tal1;
}
else {
return $tal3;
}
}
elseif ($tal2 >= $tal3) {
return $tal2;
}
else {
return $tal3;
}
}
echo "<h3>Störst av 28, 33, 11</h3>";
$result1 = compareNum(28, 33, 11);
echo "<div class=\"resultat\">$result1</div>";
echo "<h3>Störst av 55, 88, 178</h3>";
$result2 = compareNum(55, 88, 178);
echo "<div class=\"resultat\">$result2</div>";
echo "<h3>Störst av 44, 44, 28</h3>";
$result2 = compareNum(44, 44, 28);
echo "<div class=\"resultat\">$result2</div>";
?>
<?php include "../incl/footer.php"; ?>
~/webbsrvprg/exercises/funktioner $
~/webbsrvprg/exercises/funktioner $ php ovn_fn3.php
~/webbsrvprg/exercises/funktioner $