Show sourcecode
The following files exists in this folder. Click to view.
webbserverprogrammering/exercises/klasser/
klasser1.php
klasser2.php
klasser3.php
klasser4.php
klasser5.php
klasser6.php
klasser7.php
klasser3.php
49 lines UTF-8 Windows (CRLF)
<?php
error_reporting(-1);
ini_set('display_errors', 1);
ini_set('output_buffering', 0);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Klass 3</title>
</head>
<body>
<?php
class Boll {
private $färg="";
private $radie=0;
public function __construct($f, $r) {
$this->färg = $f;
$this->radie = $r;
}
public function getFärg() {
return $this->färg;
}
public function getRadie() {
return $this->radie;
}
public function setFärg($f) {
$this->färg = $f;
}
public function setRadie($r) {
$this->radie = $r;
}
}
$bollar = array();
$bollar[0] = new Boll("Röd",10);
$bollar[1] = new Boll("Grön",15);
$bollar[2] = new Boll("Gul",8);
// skriv ut informationen om våra bollar:
foreach ($bollar as $key) {
echo 'Färg: ' . $key->getFärg() . ' <br>'.'Radie: ' . $key->getRadie().'<br>';
}
?>
</body>
</html>