3v4l.org

run code in 300+ PHP versions simultaneously
<?php $mem_start = memory_get_usage(true); echo 'start: ' . $mem_start . PHP_EOL; class Foo { public static function bar() { return new Foo; } } $max_iterations = 10000; for ($i = 1; $i <= $max_iterations; $i++) { //DateTime::createFromFormat('M/D/Y H:i:s', '2013-11-12 20:00:00'); Foo::bar(); if (($i % 1000) == 0) { echo $i . '.: ' . memory_get_usage(true) . PHP_EOL; } } $mem_end = memory_get_usage(true); echo 'end: ' . $mem_end . PHP_EOL; echo 'diff end-start: ' . ($mem_end - $mem_start) . PHP_EOL;
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.26, 7.3.0 - 7.3.13, 7.4.0 - 7.4.1
start: 2097152 1000.: 2097152 2000.: 2097152 3000.: 2097152 4000.: 2097152 5000.: 2097152 6000.: 2097152 7000.: 2097152 8000.: 2097152 9000.: 2097152 10000.: 2097152 end: 2097152 diff end-start: 0
Output for 5.2.1 - 5.2.17, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
start: 262144 1000.: 262144 2000.: 262144 3000.: 262144 4000.: 262144 5000.: 262144 6000.: 262144 7000.: 262144 8000.: 262144 9000.: 262144 10000.: 262144 end: 262144 diff end-start: 0
Output for 5.3.0 - 5.3.29
start: 786432 1000.: 786432 2000.: 786432 3000.: 786432 4000.: 786432 5000.: 786432 6000.: 786432 7000.: 786432 8000.: 786432 9000.: 786432 10000.: 786432 end: 786432 diff end-start: 0
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0
Fatal error: Call to undefined function memory_get_usage() in /in/qP0UE on line 2
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/qP0UE on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/qP0UE on line 6
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/qP0UE on line 6
Process exited with code 255.

preferences:
226.66 ms | 401 KiB | 325 Q