3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo sprintf("\n%.1fMB", memory_get_usage(true) / 1024 / 1024); // allocate a large byte string of around 5 MB $a = str_repeat("0", 5 * 1024 * 1024); echo sprintf("\n%.1fMB", memory_get_usage(true) / 1024 / 1024); // setting the memory limit lower than the current is accepted ini_set("memory_limit", "3M"); echo sprintf("\n%.1fMB", memory_get_usage(true) / 1024 / 1024); // further allocation beyond the limit $b = str_repeat("0", 5 * 1024 * 1024); echo sprintf("\n%.1fMB", memory_get_usage(true) / 1024 / 1024);

preferences:
32.15 ms | 402 KiB | 5 Q