Webbserverprogrammering 1

Show sourcecode

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

webbsrvprg/exercises/klasserochobjekt/

index.php
ovn_ko1 copy.php
ovn_ko1.php
ovn_ko2.php
ovn_ko3.php
ovn_ko4.php
ovn_ko5.php
ovn_ko7.php

ovn_ko3.php

40 lines UTF-8 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>KLASSER</title>
</head>

<body>
    <?php
    
class boll  {
        private 
$color;
        private 
$radius;
        function 
__construct($color$radius){
            
$this->color $color;
            
$this->radius $radius;
        }
        function 
getInfo(){
            
// Används inte
            
return("Den här bollen är $this->color och har radien $this->radius l.e.<br>");
        }
    }
    
$bollar = [];
    
$bollar[0] = new boll("lila"2);
    
$bollar[1] = new boll("grön"123);
    
$bollar[2] = new boll("blå"123456787654323456);
    for (
$i 0$i<count($bollar); $i++){
        echo(
$bollar[$i]->getInfo());
    }
    
?>
</body>

</html>