Show sourcecode
The following files exists in this folder. Click to view.
funktion1.php
test4.php
test5.php
test6.php
test7.php
test7.php
42 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>Document</title>
</head>
<body>
<?php
class Boll {
public $farg;
public $radie;
public function __construct($farg, $radie) {
$this->farg = $farg;
$this->radie = $radie;
}
public function hej() {
echo "Min färg är $this->farg & jag är $this->radie cm <br>";
}
}
class golfboll extends Boll {
public $diameter;
public function __construct($farg, $radie, $diameter) {
parent::__construct($farg, $radie);
$this->diameter = $diameter;
}
public function hej() {
echo "Min färg är $this->farg & jag är $this->radie cm & $this->diameter cm <br>";
}
}
$fotboll = new Boll("blå", 5);
$handboll = new Boll("röd", 10);
$golfboll = new golfboll("vit", 3, 10);
$fotboll->hej();
$handboll->hej();
$golfboll->hej();
?>
</body>
</html>