<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Set whether a client disconnect should abort script execution</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.highlight-string.html">highlight_string</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.pack.html">pack</a></div> <div class="up"><a href="ref.misc.html">Misc. Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.ignore-user-abort" class="refentry"> <div class="refnamediv"> <h1 class="refname">ignore_user_abort</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">ignore_user_abort</span> — <span class="dc-title">Set whether a client disconnect should abort script execution</span></p> </div> <div class="refsect1 description" id="refsect1-function.ignore-user-abort-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">int</span> <span class="methodname"><strong>ignore_user_abort</strong></span> ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$value</code></span> ] )</div> <p class="para rdfs-comment"> Sets whether a client disconnect should cause a script to be aborted. </p> <p class="para"> 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 <em><code class="parameter">value</code></em> is set to <strong><code>TRUE</code></strong> </p> </div> <div class="refsect1 parameters" id="refsect1-function.ignore-user-abort-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">value</code></em></span> <dd> <p class="para"> If set, this function will set the <a href="misc.configuration.html#ini.ignore-user-abort" class="link">ignore_user_abort</a> ini setting to the given <em><code class="parameter">value</code></em>. If not, this function will only return the previous setting without changing it. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.ignore-user-abort-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the previous setting, as an integer. </p> </div> <div class="refsect1 examples" id="refsect1-function.ignore-user-abort-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-3781"> <p><strong>Example #1 A <span class="function"><strong>ignore_user_abort()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// Ignore user aborts and allow the script<br />// to run forever<br /></span><span style="color: #0000BB">ignore_user_abort</span><span style="color: #007700">(</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">set_time_limit</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #DD0000">'Testing connection handling in PHP'</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// Run a pointless loop that sometime <br />// hopefully will make us click away from <br />// page or click the "Stop" button.<br /></span><span style="color: #007700">while(</span><span style="color: #0000BB">1</span><span style="color: #007700">)<br />{<br /> </span><span style="color: #FF8000">// Did the connection fail?<br /> </span><span style="color: #007700">if(</span><span style="color: #0000BB">connection_status</span><span style="color: #007700">() != </span><span style="color: #0000BB">CONNECTION_NORMAL</span><span style="color: #007700">)<br /> {<br /> break;<br /> }<br /><br /> </span><span style="color: #FF8000">// Sleep for 10 seconds<br /> </span><span style="color: #0000BB">sleep</span><span style="color: #007700">(</span><span style="color: #0000BB">10</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #FF8000">// If this is reached, then the 'break' <br />// was triggered from inside the while loop<br /><br />// So here we can log, or perform any other tasks<br />// we need without actually being dependent on the <br />// browser.<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 notes" id="refsect1-function.ignore-user-abort-notes"> <h3 class="title">Notes</h3> <p class="para"> 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 <span class="function"><a href="function.flush.html" class="function">flush()</a></span>. </p> </div> <div class="refsect1 seealso" id="refsect1-function.ignore-user-abort-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.connection-aborted.html" class="function" rel="rdfs-seeAlso">connection_aborted()</a> - Check whether client disconnected</span></li> <li class="member"> <span class="function"><a href="function.connection-status.html" class="function" rel="rdfs-seeAlso">connection_status()</a> - Returns connection status bitfield</span></li> <li class="member"> <a href="features.connection-handling.html" class="link">Connection Handling</a> for a complete description of connection handling in PHP. </li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.highlight-string.html">highlight_string</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.pack.html">pack</a></div> <div class="up"><a href="ref.misc.html">Misc. Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>