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 7.0.0 - 7.0.20, 7.1.0 - 7.1.6
Fatal error: Cannot use temporary expression in write context in /in/SJqK4 on line 7
Process exited with code 255.

preferences:
192.45 ms | 1399 KiB | 35 Q