Show sourcecode
The following files exists in this folder. Click to view.
class.html
ovn_class1.php
ovn_class2.php
ovn_class3.php
ovn_class4.php
ovn_class1.php
47 lines UTF-8 Windows (CRLF)
<?php
error_reporting(-1); // Report all type of errors
ini_set('display_errors', 1); // Display all errors
ini_set('output_buffering', 0); // Do not buffer outputs, write directly
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>class 1</title>
</head>
<body>
<?php
class Boll {
public $farg;
public $radie;
public function __construct($farg, $radie) {
$this->farg = $farg;
$this->radie = $radie;
}
public function sattFarg($nyFarg) {
$this->farg = $nyFarg;
}
public function sattRadie($nyRadie) {
$this->radie = $nyRadie;
}
public function hamtaInfo() {
return "Bollen har färgen $this->farg och radien $this->radie cm.";
}
}
// Skapa en instans av klassen Boll
$minBoll = new Boll("röd", 10);
// Sätt ny färg och radie
$minBoll->sattFarg("blå");
$minBoll->sattRadie(15);
echo $minBoll->hamtaInfo();
?>
</body>
</html>