By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,189 Members | 2,167 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,189 IT Pros & Developers. It's quick & easy.

stopping php & keeping php alive

P: n/a
Hi,

First of all, I am looking for a way to force the execution of a php
script to explicitly stop when told to do so by the client
connection. I know when you hit the browser stop button php normally
stops, but it doesn't stop immediately (ie. if the script is in a
loop, it will keep going for a bit). Also, I am looking for a way to
force php to stay alive, even if the connection to the client drops.
Finally, does anyone know of a way to enable chatter between a single
php script and its client (ie. php well send out something, then the
client will respond, and then php will send another something, ...)

Thanks,
Daniel
Feb 14 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Feb 14, 9:36 am, Dan99 <power...@gmail.comwrote:
Hi,

First of all, I am looking for a way to force the execution of a php
script to explicitly stop when told to do so by the client
connection. I know when you hit the browser stop button php normally
stops, but it doesn't stop immediately (ie. if the script is in a
loop, it will keep going for a bit). Also, I am looking for a way to
force php to stay alive, even if the connection to the client drops.
Finally, does anyone know of a way to enable chatter between a single
php script and its client (ie. php well send out something, then the
client will respond, and then php will send another something, ...)

Thanks,
Daniel
Use ignore_user_abort():

<http://www.php.net/ignore_user_abort>

That will definitely answer your second question. I'm not sure if
there's much you can do about the first one, though. You might try
checking inside the loop if the connection has been aborted and then
breaking out of it.
Feb 14 '08 #2

P: n/a
On Thu, 14 Feb 2008 16:20:50 +0100, ZeldorBlat <ze********@gmail.com>
wrote:
On Feb 14, 9:36 am, Dan99 <power...@gmail.comwrote:
>Hi,

First of all, I am looking for a way to force the execution of a php
script to explicitly stop when told to do so by the client
connection. I know when you hit the browser stop button php normally
stops, but it doesn't stop immediately (ie. if the script is in a
loop, it will keep going for a bit). Also, I am looking for a way to
force php to stay alive, even if the connection to the client drops.
Finally, does anyone know of a way to enable chatter between a single
php script and its client (ie. php well send out something, then the
client will respond, and then php will send another something, ...)

Thanks,
Daniel

Use ignore_user_abort():

<http://www.php.net/ignore_user_abort>

That will definitely answer your second question. I'm not sure if
there's much you can do about the first one, though. You might try
checking inside the loop if the connection has been aborted and then
breaking out of it.
In a HTML context, spaces are no content, and if you have no buffering
mechanism somewhere, a simple statement like this in every loop:
echo ' ';
flush();
if(connection_aborted()) exit;

....could very well halt execution sooner. However, if you need to stop
'dead on', HTTP is not the way to go.
--
Rik Wasmus
Feb 14 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.