Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
dvprog_14 [2020-05-18 20:17]
Daniel Viström
dvprog_14 [2020-05-18 20:17]
Daniel Viström
Line 12: Line 12:
  
 ==== Exempel 1 ==== ==== Exempel 1 ====
 +<code php>
 +<?php
 +include 'head.php';
 +
 +$a = new Counter();
 +echo $a->getValue() . '<br>';
  
 +// $a->value--; // Går inte att komma åt eftersom attributet är private.
 +
 +$i = 0;
 +while ($i < 20){
 +  $a->klick();
 +  $i++;
 +}
 +echo $a->getValue() . '<br>';
 +
 +$b = new Counter();
 +$b->klick();
 +echo $b->getValue() . '<br>';
 +
 +$b->zero();
 +echo $b->getValue() . '<br>';
 +
 +include 'foot.php';
 +
 +</code>
 <code php> <code php>
 <?php <?php
Line 38: Line 63:
   }   }
 } }
-</code> 
- 
- 
-<code php> 
-<?php 
-include 'head.php'; 
- 
-$a = new Counter(); 
-echo $a->getValue() . '<br>'; 
- 
-// $a->value--; // Går inte att komma åt eftersom attributet är private. 
- 
-$i = 0; 
-while ($i < 20){ 
-  $a->klick(); 
-  $i++; 
-} 
-echo $a->getValue() . '<br>'; 
- 
-$b = new Counter(); 
-$b->klick(); 
-echo $b->getValue() . '<br>'; 
- 
-$b->zero(); 
-echo $b->getValue() . '<br>'; 
- 
-include 'foot.php'; 
- 
 </code> </code>