3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class ArrayTester { const TEST_LOOP_SIZE = 1000000; public function go() { $start = microtime(true); for($a = 0; $a<=self::TEST_LOOP_SIZE;++$a) { $test = $this->getTest(); $someVal = $test[$a]; } echo 'Pass by copy: ' . (microtime(true) - $start) . ' sec<br>'; $start = microtime(true); for($a = 0; $a<=self::TEST_LOOP_SIZE;++$a) { $test = &$this->getTestByRef(); $someVal = $test[$a]; } echo 'Pass by reference: ' . (microtime(true) - $start) . ' sec<br>'; } private $_test; private function getTest() { if(!$this->_test) { for($a = 0; $a<=self::TEST_LOOP_SIZE;++$a) { $this->_test[$a]=md5($a); } } return $this->_test; } private $_testByRef; private function &getTestByRef() { if(!$this->_testByRef) { for($a = 0; $a<=self::TEST_LOOP_SIZE;++$a) { $this->_testByRef[$a]=md5($a); } } return $this->_testByRef; } } $tester = new ArrayTester(); $tester->go();
based on sRRL8
Output for 7.0.0 - 7.1.0
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 33554440 bytes) in /in/9WjBt on line 27
Process exited with code 255.
Output for hhvm-3.12.0
Pass by copy: 0.70811820030212 sec<br>mallctl opt.prof: No such file or directory (2) Fatal error: request has exceeded memory limit in /in/9WjBt on line 36
Process exited with code 255.
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.4.0 - 5.4.9, 5.6.7 - 5.6.28
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 72 bytes) in /in/9WjBt on line 27
Process exited with code 255.
Output for 5.4.10 - 5.5.35
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /in/9WjBt on line 27
Process exited with code 255.
Output for 5.2.1, 5.2.6, 5.2.10 - 5.3.29
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 71 bytes) in /in/9WjBt on line 27
Process exited with code 255.
Output for 5.2.7 - 5.2.9
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 33 bytes) in /in/9WjBt on line 27
Process exited with code 255.
Output for 5.2.2 - 5.2.5
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 24 bytes) in /in/9WjBt on line 27
Process exited with code 255.
Output for 5.0.0 - 5.2.0

Process exited with code 137.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/9WjBt on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/9WjBt on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/9WjBt on line 4
Process exited with code 255.