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', 10000000); echo memory_get_usage() . ":" . rand(1,4) ; echo PHP_EOL; } echo "WHILE ENDS in $a"; echo PHP_EOL; } echo "WORK FINE";

preferences:
31.7 ms | 402 KiB | 5 Q