3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php const INT_COUNT = 1000000; // Fill an array with random ints $ints = []; for ($i = 0; $i < INT_COUNT; $i++){ $ints[] = rand(0, 255); } // Sort the ints sort($ints); $start = microtime(true); // Do nothing but access each int in the array for ($i = 0; $i < INT_COUNT; $i++){ $ints[$i]; } $finish = microtime(true); printf("Time taken with sort(): %.3f seconds\n", $finish - $start); // Now do it again, but this time use an asort // Fill an array with random ints $ints = []; for ($i = 0; $i < INT_COUNT; $i++){ $ints[] = rand(0, 255); } // asort the ints asort($ints); $start = microtime(true); // Do nothing but access each int in the array for ($i = 0; $i < INT_COUNT; $i++){ $ints[$i]; } $finish = microtime(true); printf("Time taken with asort(): %.3f seconds\n", $finish - $start);
Output for 7.1.0
Time taken with sort(): -0.017 seconds Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 37748736 bytes) in /in/VL3ch on line 34
Process exited with code 255.
Output for 7.0.14
Time taken with sort(): 0.019 seconds Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 37748736 bytes) in /in/VL3ch on line 34
Process exited with code 255.
Output for 7.0.0, 7.0.2 - 7.0.6, 7.0.8 - 7.0.9
Time taken with sort(): 0.016 seconds Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 37748736 bytes) in /in/VL3ch on line 34
Process exited with code 255.
Output for 7.0.1, 7.0.7
Time taken with sort(): 0.017 seconds Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 37748736 bytes) in /in/VL3ch on line 34
Process exited with code 255.
Output for 5.4.0 - 5.6.28
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /in/VL3ch on line 7
Process exited with code 255.
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/VL3ch on line 5
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_CONST in /in/VL3ch on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_CONST in /in/VL3ch on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/VL3ch on line 2
Process exited with code 255.