3v4l.org

run code in 300+ PHP versions simultaneously
<?php class version_info { private $vi; function __construct() { $this->vi = array(); } function add($name, $filename) { $this->vi[$filename] = array( 'name' => $name, 'filename' => $filename ); } function dump() { // temporary for debugging foreach ($this->vi as $item) { //echo $item['name'] . ' ' . $item['filename'] . "\n"; echo "$item['name'] $item['filename']\n"; } } } $sc_version_info = new version_info(); $sc_version_info->add('Test', '/admin/test.php'); f('Test2', '/admin/test2.php'); $sc_version_info->dump(); function f($a, $b) { global $sc_version_info; $sc_version_info->add($a, $b); }
Output for 5.4.0 - 5.4.22
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /in/lirP1 on line 17
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /in/lirP1 on line 17
Process exited with code 255.

preferences:
184.02 ms | 1395 KiB | 58 Q