Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
dvprog_14 [2020-05-18 20:17] Daniel Viström |
dvprog_14 [2020-05-18 20:20] Daniel Viström |
||
---|---|---|---|
Line 12: | Line 12: | ||
==== Exempel 1 ==== | ==== Exempel 1 ==== | ||
- | |||
- | <code php> | ||
- | <?php | ||
- | |||
- | // Klassen kan ligga i samma fil som huvudprogrammet, | ||
- | |||
- | class Counter{ | ||
- | |||
- | private $value; | ||
- | | ||
- | public function __construct(){ | ||
- | $this-> | ||
- | } | ||
- | | ||
- | public function klick(){ | ||
- | $this-> | ||
- | } | ||
- | | ||
- | public function getValue(){ | ||
- | return $this-> | ||
- | } | ||
- | | ||
- | public function zero(){ | ||
- | $this-> | ||
- | } | ||
- | } | ||
- | </ | ||
- | |||
- | |||
<code php> | <code php> | ||
<?php | <?php | ||
+ | include ' | ||
include ' | include ' | ||
Line 66: | Line 38: | ||
include ' | include ' | ||
+ | </ | ||
+ | |||
+ | Klassen **Counter** ligger i en separat fil, **counter.php**. \\ | ||
+ | Klassen kan ligga i samma fil som huvudprogrammet, | ||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | class Counter{ | ||
+ | |||
+ | private $value; | ||
+ | | ||
+ | public function __construct(){ | ||
+ | $this-> | ||
+ | } | ||
+ | | ||
+ | public function klick(){ | ||
+ | $this-> | ||
+ | } | ||
+ | | ||
+ | public function getValue(){ | ||
+ | return $this-> | ||
+ | } | ||
+ | | ||
+ | public function zero(){ | ||
+ | $this-> | ||
+ | } | ||
+ | } | ||
</ | </ | ||
Line 72: | Line 71: | ||
<code php> | <code php> | ||
<?php | <?php | ||
- | include ' | ||
include ' | include ' | ||
+ | include ' | ||
$a1 = new Animal(); | $a1 = new Animal(); |