Webbserverprogrammering 1

Show sourcecode

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

webbserverprogrammering/exercises/klasser/

ovning_1.php
ovning_2.php
ovning_3.php
ovning_4.php
ovning_5.php

ovning_1.php

33 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">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/dark.css">
  <title>Övning 1</title>
</head>
<body>
  <?php
    
class Ball {
      public 
$name;
      public 
$color;
      public 
$radius;

      function 
set_color($color) {
        
$this->color $color;
      }
      function 
set_radius($radius) {
        
$this->radius $radius;
      }
    }

    
$blue_ball = new Ball();
    
$blue_ball->set_color("blå");
    
$blue_ball->set_radius(2);

    echo 
"Bollens färg är $blue_ball->color";
    echo 
"<br>";
    echo 
"Bollens radie är $blue_ball->radius"."cm";
  
?>
</body>
</html>