Re: [PHP] set-time-limit

2005-01-27 Thread Richard Lynch
Wiberg wrote:
 why is it so that when I echo something to the screen then I can run the
 script for a longer time, than if I don't have echo? Don't get the
 logic...

Somewhere, deep in the guts of PHP, there is something not unlike this:

if (exceeded_time_limit()){
  trigger_error(Time limit exceeded., E_ERROR);
  exit;
}
process_next_php_instruction();

Now, sometimes, process_next_php_instruction() may be reduced to a very
very very simple tight loop in C or Assembler or byte-code or whatever you
care to think of it as.

Without the 'echo' in your code, PHP treats your code as an atomic unit to
be processed (including the loop) and never gives itself the opportunity
to break out with the test about time limit.

When you add the 'echo' statement, that gives PHP a chance to break in
to the tight loop and check the time on it, because now you've got TWO
instructions where before you only really had ONE.

PHP also doesn't count time spent in certain tasks, for reasons that are
not apparent to me, but some would probably boil down to That would be
really hard to do deep in the guts of the PHP code.

In some case, though, it's by design:  They're trying *NOT* to count it
against you if your database server takes forever to respond, or if your
fopen('http://...') takes forever to respond.

The purpose of the PHP php.ini time limit is to avoid an infinite loop in
your PHP script taking down the server, not a hard-and-fast absolute limit
on the number of seconds any given PHP script should live.

Or, in other words, the timing in PHP that decides when you've used up
to much cpu time is at a relatively high level of processing/language
interpretation, and only applies to actual PHP code being executed, not
down at the raw CPU timing level.

This has advantages and disadvantages, of course, but that's why it is the
way it is.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] set-time-limit

2005-01-26 Thread Wiberg
Hi!

when safe mode is one, i can't use set_time_limit. Is there any workarounds?

why is it so that when I echo something to the screen then I can run the
script for a longer time, than if I don't have echo? Don't get the logic...

/G
@varupiraten.se

--
Internal Virus Database is out-of-date.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.7.1 - Release Date: 2005-01-19

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php