Webbserverprogrammering 1

Show sourcecode

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

webbsrvprg/exercises/

index.php
ovn1_gr.php
ovn2_fn.php
ovn3_inkl.php
ovn3_inklfil.php
ovn3_inklfil2.php
ovn3_inklsida1.php
ovn3_inklsida2.php
ovn3_inklsida3.php
ovn3_inklsidafil.php
ovn4_form.php
ovn4_mottagare.php
ovn4_mottagare2.php
ovn4_mottagare3.php
ovn4_mottagare4.php
quiz.php

ovn2_fn.php

125 lines ASCII Windows (CRLF)
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

<?php
function text1(){
    echo 
"Hejsansvejsan!";
}
echo 
"1. ";
text1()
?>
<br>

<?php
echo "2. ";
function 
text2(int $antal){
    for(
$i = 0; $i <= $antal; $i++)
        echo 
"Hejsansvejsan! ";
}
text2(6);
?>
<br>

<?php
echo "3. ";
function 
jamfor(int $tal1, int $tal2, int $tal3 ){
    if (
$tal1 > $tal2){
        if (
$tal1 > $tal3){
            return 
$tal1;
        }
        else {
            return 
$tal3;
        }
    }
    elseif (
$tal2 > $tal1){
        if (
$tal2 > $tal3){
        return 
$tal2;
        }
        else {
            return 
$tal3;
        }
    }
}
echo 
jamfor(3, 12, 9)
?>
<br>

<?php
echo "4. ";
function 
jamfor2(int $tal1, int $tal2, int $tal3, string $minsta = "minsta"){
    if (
$minsta == "minsta"){
        if (
$tal1 < $tal2){
            if (
$tal1 < $tal3){
                return 
$tal1;
            }
            else {
                return 
$tal3;
            }
        }
        elseif (
$tal2 < $tal1){
            if (
$tal2 < $tal3){
            return 
$tal2;
            }
            else {
                return 
$tal3;
            }
        }else
            if (
$tal1 > $tal2){
                if (
$tal1 > $tal3){
                    return 
$tal1;
                }
                else {
                    return 
$tal3;
                }
            }
            elseif (
$tal2 > $tal1){
                if (
$tal2 > $tal3){
                return 
$tal2;
                }
                else {
                    return 
$tal3;
                }
            }
        }
}
echo 
jamfor2(3, 12, 9, "minsta")
?>
<br>

<?php
echo "5. ";
function 
varde(int...$list){
    
$antal2 = count($list);
    
$sum = 0;
    for(
$i=0; $i<$antal2; $i++)
        
$sum += $list[$i];
    return 
$sum/$antal2;
}
echo 
varde(1, 4, 17, 9, 11, 18, 31, 13);
?>
<br>

<?php
echo "6. ";
function 
valter(int...$list2){
    
$antal3 = count($list2);
    
$sum2 = 0;
    for(
$i=0; $i<$antal3; $i++)
        
$sum2 += $list2[$i];
    if(
$sum2 % 2 == 0){
        return 
"0";
        }
    else
        return 
$sum2;
    
}
echo 
valter(2, 3, 17, 9, 11, 18, 31, 13);
?>
</body>
</html>