Webbserverprogrammering 1

Show sourcecode

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

webb_serv/ovningar/grunder/

ovning1.php
ovning2.php
ovning3.php
ovning4.php
ovning5.php
test.php

ovning4.php

52 lines UTF-8 Windows (CRLF)
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>gr_ovning4</title>
</head>
<body>
    <?php
        $celsius 
= -20;

        
$values_C = array();
        
$values_F = array();

        function 
convertToFarenhite($cel){
            
$f = ($cel * 9/5) + 32;
            return 
$f;
        }

        while (
$celsius < 40){
            
$f = convertToFarenhite($celsius);
            echo (
$celsius. " °C : ");
            echo (
$f. " °F ");

            
$values_C[] = $celsius;
            
$values_F[] = $f;

            
$celsius += 10;

            echo (
"<br>");
        }

        echo (
"<br>". "<br>". "<br>". "<br>");

        echo (
"°C: ");
        
var_dump($values_C);

        echo (
"<br>");

        echo (
"°F: ");
        
var_dump($values_F);

        echo (
"<br>". "<br>". "<br>". "<br>");

        for (
$i = 1; $i <= count($values_C); $i++){
            echo (
"°C: ". $values_C[$i - 1]. " : ");
            echo (
"°F: ". $values_F[$i - 1]);

            echo(
"<br>");
        }
    
?>
</body>
</html>