I have a simple infinite recursive code here:
<?php
function test() {
test();
}
test();
When I try to run the same, it eats up all the memory and eventually my laptop hangs. What I am looking for is a way to catch this and stop the machine from hanging. Is there any error handler in PHP for the same?
Things I have read and tried: setting max_execution_time to, let’s say, 5 seconds and catch the error line number. This didn’t work as proposed.
Is there another way to catch and stop this?
I am using Ubuntu 16.04.1 LTS (Xenial Xerus).