3v4l.org

run code in 300+ PHP versions simultaneously
<?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);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Fatal error: Uncaught Error: Undefined constant test::callCounters in /in/SgYsC:23 Stack trace: #0 {main} thrown in /in/SgYsC on line 23
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
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.

preferences:
194.61 ms | 403 KiB | 174 Q