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);
Output for 7.0.0 - 7.1.6
Fatal error: Cannot use temporary expression in write context in /in/SJqK4 on line 7
Process exited with code 255.
Output for hhvm-3.15.4
Fatal error: Uncaught Error: syntax error, unexpected '=' in /in/SJqK4:7 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in /in/SJqK4 on line 6
Process exited with code 255.