note 92949 added to function.set-time-limit

From: Date: Sat, 15 Aug 2009 23:46:00 +0000
Subject: note 92949 added to function.set-time-limit
Groups: php.notes 
Request: Send a blank email to php-notes+get-159534@lists.php.net to get a copy of this message
Unfortunately, a script which gets into an infinite loop can produce an alarming amount of output in only a few seconds. I was attempting to debug a script, and I added <?php set_time_limit(2); ?> to the beginning of the script. Unfortunately, even two seconds of run time produced enough output to overload the memory available to my browser. So, I wrote a short routine which would limit the execution time, and also limit the amount of output returned. I added this to the beginning of my script and it worked perfectly: <?php set_time_limit(2); ob_start(); // buffer output function shutdown () { // print only first 2000 characters of output $out = ob_get_clean(); print substr($out, 0, 2000); } register_shutdown_function('shutdown'); ?> ---- Server IP: 64.71.164.2 Probable Submitter: 67.165.168.203 ---- Manual Page -- http://www.php.net/manual/en/function.set-time-limit.php Edit -- https://master.php.net/note/edit/92949 Del: integrated -- https://master.php.net/note/delete/92949/integrated Del: useless -- https://master.php.net/note/delete/92949/useless Del: bad code -- https://master.php.net/note/delete/92949/bad+code Del: spam -- https://master.php.net/note/delete/92949/spam Del: non-english -- https://master.php.net/note/delete/92949/non-english Del: in docs -- https://master.php.net/note/delete/92949/in+docs Del: other reasons-- https://master.php.net/note/delete/92949 Reject -- https://master.php.net/note/reject/92949 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#159534) next »