ignore_user_abort
(PHP 4, PHP 5, PHP 7)
ignore_user_abort — Set whether a client disconnect should abort script execution
Description
$value
] ) : intSets whether a client disconnect should cause a script to be aborted.
When running PHP as a command line script, and the script's tty goes
away without the script being terminated then the script will die the
next time it tries to write anything, unless
value
is set to TRUE
Parameters
-
value
-
If set, this function will set the ignore_user_abort ini setting to the given
value
. If not, this function will only return the previous setting without changing it.
Examples
Example #1 A ignore_user_abort() example
<?php
// Ignore user aborts and allow the script
// to run forever
ignore_user_abort(true);
set_time_limit(0);
echo 'Testing connection handling in PHP';
// Run a pointless loop that sometime
// hopefully will make us click away from
// page or click the "Stop" button.
while(1)
{
// Did the connection fail?
if(connection_status() != CONNECTION_NORMAL)
{
break;
}
// Sleep for 10 seconds
sleep(10);
}
// If this is reached, then the 'break'
// was triggered from inside the while loop
// So here we can log, or perform any other tasks
// we need without actually being dependent on the
// browser.
?>
Notes
PHP will not detect that the user has aborted the connection until an attempt is made to send information to the client. Simply using an echo statement does not guarantee that information is sent, see flush().
See Also
- connection_aborted() - Check whether client disconnected
- connection_status() - Returns connection status bitfield
- Connection Handling for a complete description of connection handling in PHP.
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-ignore-user-abort.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.