Webbserverprogrammering 1

Show sourcecode

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

webbsrvprg/exercises/funktioner/

index.php
ovn_fn1 copy.php
ovn_fn1+2.php
ovn_fn3+4.php
ovn_fn5.php
ovn_fn6.php
ovn_fn7.php

ovn_fn6.php

42 lines ASCII Windows (CRLF)
<?php
error_reporting
(-1); // Report all type of errors
ini_set('display_errors'1); // Display all errors
ini_set('output_buffering'0); // Do not buffer outputs, write directly
?>

<!DOCTYPE html>
<html lang="sv">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Funktioner</title>
</head>

<body>

    <?php
    $arr 
= [1,2,3,4,5,6,7,8,9,100];
    
    function 
doThing($arr){
        for (
$i 0$i<count($arr);$i++){
            if(!(
$arr[$i] % 2)){
                
$arr[$i] = 0;
            }
        }
        return(
$arr);
    }

    function 
writeArr($arr){
        for (
$i 0$i<count($arr);$i++){
            echo(
$arr[$i] . "  ");
        }
        echo(
"<br>");
    }
    
writeArr($arr);
    
writeArr(doThing($arr));
    
?>

</body>

</html>