Webbserverprogrammering 1

Show sourcecode

The following files exists in this folder. Click to view.

Webbsrvprg/exercises/

databas/
dbtestforfattare.php
forms/
funktioner/
grunder/
incl/
include/
index.php
ovn_fn1.php
ovn_fn2.php
ovn_fn3.php
ovn_fn4.php
ovn_fn5.php
ovn_fn6.php
ovn_gr1.php
ovn_gr2.php
ovn_gr3.php
ovn_gr4.php
ovn_gr5.php
ovn_incl1.php
ovningar.css
resultatsidor/

ovn_fn3.php

39 lines UTF-8 Unix (LF)
<?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"; ?>