3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class test { public static $callCounters = []; public function call($index) { if (!isset(self::$callCounters[$index])) { self::$callCounters[$index] = 0; } ++self::$callCounters[$index]; } }; $x = new test(); $indexes = range('a','e'); foreach($indexes as $index) { for($i = 0; $i <= 2; ++$i) { $x->call($index); } } var_dump(test::callCounters);
based on SJqK4
Output for 7.0.0 - 7.3.0rc3
Fatal error: Uncaught Error: Undefined class constant 'callCounters' in /in/SgYsC:23 Stack trace: #0 {main} thrown in /in/SgYsC on line 23
Process exited with code 255.
Output for hhvm-3.15.4
Fatal error: Uncaught Error: Couldn't find constant test::callCounters in /in/SgYsC:23 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Fatal error: Undefined class constant 'callCounters' in /in/SgYsC on line 23
Process exited with code 255.