3v4l.org

run code in 300+ PHP versions simultaneously
<?php //ini_set('memory_limit', '1M'); register_shutdown_function(function(){ echo "SHUTDOWN"; echo PHP_EOL; $error = error_get_last(); if (isset($error)) { if (0 === strpos($error['message'], 'Allowed memory size')) { // ini_set('memory_limit', -1); w('AFTER ERROR'); } } }); w('FIRST'); function w($a) { echo $a; echo PHP_EOL; $r = 1000000; while($r--) { $m = str_repeat('a', 100000000); echo memory_get_usage() . ":" . rand(1,4) ; echo PHP_EOL; } echo "WHILE ENDS in $a"; echo PHP_EOL; } echo "WORK FINE";
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.25, 7.3.0 - 7.3.12, 7.4.0
FIRST Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 100000032 bytes) in /in/BKt8W on line 30 SHUTDOWN AFTER ERROR Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 100000032 bytes) in /in/BKt8W on line 30
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.35, 5.6.0 - 5.6.28
FIRST Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 100000001 bytes) in /in/BKt8W on line 30 SHUTDOWN AFTER ERROR
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/BKt8W 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, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION, expecting ')' in /in/BKt8W on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/BKt8W on line 6
Process exited with code 255.

preferences:
230.93 ms | 401 KiB | 253 Q