> > That's not true. If you use register_shutdown_function() then this
> > function you register will be run once the timeout hits. See the chapter
> > in the manual on connection handling.
> But this still doesn't let you apply a timeout to a specific block of code.
> I am doing ad calls to a remote server with PHP, and I want to be able to
> timeout just the readfile() function I'm using to do the call, and to
> execute an alternate block of code when it times out. I don't want to abort
> execution of the entire script; just that portion thereof.
Right, but when you are doing network work like this you should be using
fsockopen() directly which does have timeout support. readfile() with a
url argument just does a simple fsockopen anyway and issues a GET request.
Trivial to do yourself using fsockopen() and fputs() and this way you can
manage the timeouts yourself. Introducing a language-level timeout
feature is complicated.
> I am including a small file with some PHP code in a larger script; can I
> have a separate timeout for the included script, or does it apply to the
> main script? If I could have separate timeouts for included scripts, it
> could serve as a workaround for using timeouts on specific blocks of code.
No, included files are part of the same script.
We do have the 'ticks' feature which lets you identify a block of code
that will be interrupted every now and and a function you define is
called. Doesn't quite do what you need though. The best approach for you
is to just use fsockopen().
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]