Show sourcecode
The following files exists in this folder. Click to view.
ovn_klass1.php
ovn_klass2.php
ovn_klass3.php
ovn_klass4.php
ovn_klass5.php
ovn_klass6.php
ovn_klass7.php
ovn_klass2.php
43 lines UTF-8 Windows (CRLF)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Klasser 2</title>
</head>
<body>
<?php
class Boll {
private $färg;
private $radie;
public function __construct($färg, $radie) {
$this->färg = $färg;
$this->radie = $radie;
}
public function getFärg(){
echo "Bollen är ". $this->färg. "<br>";
}
public function getRadie(){
echo "Radien är ".$this->radie. "<br>";
}
}
$boll1 = new Boll("röd","5");
$boll1->getFärg();
$boll1->getRadie();
$boll2 = new Boll("blå","9");
$boll2->getFärg();
$boll2->getRadie();
$boll3 = new Boll("grön","100");
$boll3->getFärg();
$boll3->getRadie();
?>
</body>
</html>