ikebowen Posted July 5, 2007 Share Posted July 5, 2007 header( "content-disposition: attachment" ); $foo = md5( "foo" ); while ( 1 < 2 ) echo( "$foo\n" ); Inexplicably, the code above (and that code alone) blows straight past max_execution_time's 30sec limit and goes on for, as far as I can tell, infinity. Or until a server tech notices. Any ideas why? I wrote up a more detailed dissertation at ikebowen.com; would appreciate it if you guys would take a look. I promise this isn't a site plug, I'm just seriously confounded. This has very little implications on anything, but it's really starting to annoy. Makes no sense at all. Quote Link to comment Share on other sites More sharing options...
xyn Posted July 5, 2007 Share Posted July 5, 2007 I have a simelar problem, just phph isnt executing your code... so i would suggest: CHANGE THIS: while ( 1 < 2 ) echo( "$foo\n" ); TO THIS $display = md5('foo'); $max = 2; // max amoutn of times to run this query. for($i=0; $i<$max; $i++) $display .= $display; // starts from 0, and keeps repeating until it hits the max. ie: value of $max echo $display; Quote Link to comment Share on other sites More sharing options...
arhhook Posted July 5, 2007 Share Posted July 5, 2007 I believe ike's issue wasn't getting the code to run twice or whatever $max is; while ( 1 < 2 ) echo( "$foo\n" ); simply blows past max_execution_time and will not terminate when expected (after 30 seconds). It is a curious thing? Because while ( 1 < 2) is an infinite conditional statement (it can never be reached where 1 > 2; the statement will keep repeating) until..well..until max_execution_time stops it at 30 seconds or whatever that's set to and then it should terminate, however it isn't killing the thread. Quote Link to comment Share on other sites More sharing options...
ikebowen Posted July 5, 2007 Author Share Posted July 5, 2007 Right - my question is why the script doesn't stop at 30sec like it should. What would cause it to get past the max execution time? Quote Link to comment Share on other sites More sharing options...
xyn Posted July 5, 2007 Share Posted July 5, 2007 I believe ike's issue wasn't getting the code to run twice or whatever $max is; I understand now. sorry & I'm not completely sure, but it could be changed by checking PhpInfo for the name or title and use... ini_set('max_execution_time', '30'); Update: Make sure that is added at the top of any page.. Quote Link to comment Share on other sites More sharing options...
ikebowen Posted July 5, 2007 Author Share Posted July 5, 2007 And if I had any practical reason for echoing the md5 of "foo" a finite number of times, I'd do that. Quote Link to comment Share on other sites More sharing options...
ikebowen Posted July 6, 2007 Author Share Posted July 6, 2007 Right... bad forum etiquette here. *bump Just looking for some conjectures as to why the code posted above goes beyond max_execution_time. Anyone feel like testing it on another server? Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 6, 2007 Share Posted July 6, 2007 ok i think it will do for the loop before it reach the max use the header then put a query string so loop start at the given query string s that wht you mean :'( Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.