- var_dump: documentation ( source)
<?php
class Counter {
private $counter = 0;
public function getCount() { return $this->counter; }
public function increment() { $this->counter = $this->getCount() + 1; }
}
class CounterOfssetByOne extends Counter {
public function getCount() { return parent::getCount() + 1; }
}
$counter = new CounterOfssetByOne;
$counter->increment();
$counter->increment();
var_dump($counter->getCount());