Webbserverprogrammering 1

Show sourcecode

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

webbsrvprg/exercises/klasser/

klasser.php
klasser1.php
klasser2.php
klasser3.php
klasser4.php
klasser5.php
klasser6.php
klasser7.php
klasser8.php

klasser2.php

35 lines UTF-8 Windows (CRLF)
<!DOCTYPE html>
<html lang="en">
<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 
$färg;
    private 
$radie;
    private 
$num;

    function 
__construct($färg$radie$num) {
      
$this->färg $färg;
      
$this->radie $radie;
      
$this->num $num;
    }

    public function 
info() {
      echo 
"Boll nummer $this->num är $this->färg och har radien $this->radie m<br>";
    }
  }

  
$boll1 = new Boll("röd"51);
  
$boll2 = new Boll("gul"22);
  
$boll3 = new Boll("blå"103);

  
$boll1->info();
  
$boll2->info();
  
$boll3->info();
  
?>
</body>
</html>