Show sourcecode
The following files exists in this folder. Click to view.
public_html/exercises/klasser/
ovn_klass1.php
ovn_klass2.php
ovn_klass3.php
ovn_klass2.php
40 lines ASCII 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 1</title>
</head>
<body>
<?php
class Ball {
// Properties
private $color = '';
private $radius = 0;
public function __construct($color, $radius) {
$this->color = $color;
$this->radius = $radius;
}
// Methods
public function get_color() {
return $this->color;
}
public function get_radius() {
return $this->radius;
}
}
$boll1 = new Ball("Blue", 5);
$boll2 = new Ball("Red", 9);
echo $boll1->get_color();
echo $boll1->get_radius();
echo "<br>";
echo $boll2->get_color();
echo $boll2->get_radius();
?>
</body>
</html>