Show sourcecode
The following files exists in this folder. Click to view.
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", 5, 1);
$boll2 = new Boll("gul", 2, 2);
$boll3 = new Boll("blå", 10, 3);
$boll1->info();
$boll2->info();
$boll3->info();
?>
</body>
</html>