Is there a way you can abort a block of code if it\'s taking too long in PHP? Perhaps something like:
//Set the max time to 2 seconds $time = new TimeOut(2); $ti
Here is my way to do that. Thanks to others answers:
self::$timeout) { throw new \RuntimeException($error ?? 'You code took too much time.'); } } public static function step() : void { usleep(1); } }
Then you can try like this:
getMessage(); // 'You code is heavy. Sorry.' }