PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
The problem is that, if I try to browse the file containing this code and I close the browser after a couple of seconds, the execution doesn't stop and, at the end, myFile.txt contains all the 15 '*' characters.
What I'm doing wrong?
Hi feyd,
and thank you for you answer.
You're right, I'm not sending anything to the user, but, closing the browser, I also close the TCP connection to the web server and I thought that it was the web server to forward this information to the PHP engine.
The misunderstanding was also due to what the PHP manual says "ignore_user_abort -- Set whether a client disconnect should abort script execution". It doesn't say anything about user output.
Anyway, does this mean that, if I have a function which doesn't send anything to the user, I can be sure that it will not be interrupted despite of the value of ignore_user_abort?
You're right again, but I was speaking theoretically.
My question is: if a piece of code doesn't send anything to the user, can be interrupted by a user abort if ignore_user_abort is set to FALSE?
If, for example, I have some code which
1) Send something to the user
2) Executes some code without any output
3) Send something else to the user
The problem is that, if I try to browse the file containing this code and I close the browser after a couple of seconds, the execution doesn't stop and, at the end, myFile.txt contains all the 15 '*' characters.
What I'm doing wrong?
I don't entirely understand your question - ignore_user_abort is meant to keep the script running even after the user closes his browser session with the page. So, if you close your browser after a "couple of seconds", and it writes all 15 *'s, doesn't that mean the script is working? Or maybe I misread something.
JeFFb68CAM wrote:I don't entirely understand your question - ignore_user_abort is meant to keep the script running even after the user closes his browser session with the page. So, if you close your browser after a "couple of seconds", and it writes all 15 *'s, doesn't that mean the script is working? Or maybe I misread something.
JeFFb68CAM wrote:I don't entirely understand your question - ignore_user_abort is meant to keep the script running even after the user closes his browser session with the page. So, if you close your browser after a "couple of seconds", and it writes all 15 *'s, doesn't that mean the script is working? Or maybe I misread something.
Ok, I took a look at the PHP source code and, if I didn't miss anything, I now have the answer.
The "ignore_user_abort" flag is only checked when PHP receive an error trying to output something to the user.
So, in my understanding, there is no way to interrupt code which doesn't produce any output.