Is it possible to have code that acts like a 'thread' in PHP, that I can set to always be running while my script runs. The reason for this is because the browser will drop connections if it doesn't see some kind of input after a while and I want to avoid using ignore_user_abort() for obvious reasons, not to mention my script is kid of a 'progress showing script', but the progress might not show for a while as data is coming in from URL's. So I ask, is it possible to create a background task like a 'thread' in php while my other code executes. I could make that thread just print out random 'dots' to keep the code from stopping.
You can enter a forever loop and just keep it running, yes. It would be a different process rather than a thread so you'd not have control over it from your main program. However you can work around by sending "signals" to that daemon.
If data is being given to the browser, it won't drop the connection. Simply set ob_implicit_flush(true); to make sure echo() or print() statements are flushed to the browser as soon as they are executed. You could also execute flush() then ob_flush() just to be safe. Jay
better, i suggest you to use AJAX, in javascript you can timely make a call to a php page to make it execute.. in this way your thread issue will also solve using javascript settimeout method...