3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Counter { private $counter = 0; private 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());
based on hQR0N
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to private method Counter::getCount() from context 'CounterOfssetByOne' in /in/qp778:10 Stack trace: #0 /in/qp778(17): CounterOfssetByOne->getCount() #1 {main} thrown in /in/qp778 on line 10
Process exited with code 255.
Output for 5.3.19 - 5.6.28
Fatal error: Call to private method Counter::getCount() from context 'CounterOfssetByOne' in /in/qp778 on line 10
Process exited with code 255.