Webbserverprogrammering 1

Show sourcecode

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

webbserverprogrammering/exercises/classes/

classes.php
classes1.php
classes2.php
classes3.php
classes4.php
classes5.php

classes1.php

41 lines UTF-8 Windows (CRLF)
<!DOCTYPE html>
<html lang="sv">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>classes1</title>
</head>
<body>
  <?php
  
class Ball_a {
    
// Egenskaper
    
private $color;
    private 
$radius;

    
// Metoder
    
public function set_color($color) {
      
$this->color $color;
    }
    public function 
set_radius($radius) {
      
$this->radius $radius;
    }
    public function 
get_color() {
      return 
$this->color;
    }
    public function 
get_radius() {
      return 
$this->radius;
    }
  }

  
$ball_1 = new Ball_a();
  
$ball_1->set_color('Green');
  
$ball_1->set_radius('1 dm');

  echo 
"Boll 1";
  echo 
"<hr style=\"width: 200px; margin-left: 0;\">";
  echo 
"Färg: " $ball_1->get_color();
  echo 
"<br>";
  echo 
"Radie: " $ball_1->get_radius();
  
?>
</body>
</html>