Source of: /manual/en/function.ignore-user-abort.php
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.misc.inc";
$setup = array (
'home' =>
array (
0 => 'index.php',
1 => 'PHP Manual',
),
'head' =>
array (
0 => 'UTF-8',
1 => 'en',
),
'this' =>
array (
0 => 'function.ignore-user-abort.php',
1 => 'ignore_user_abort',
),
'up' =>
array (
0 => 'ref.misc.php',
1 => 'Misc. Functions',
),
'prev' =>
array (
0 => 'function.highlight-string.php',
1 => 'highlight_string',
),
'next' =>
array (
0 => 'function.pack.php',
1 => 'pack',
),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);
manual_header();
?>
<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>
<a name="function.ignore-user-abort.description"></a><div class="refsect1 description">
<h3 class="title">Description</h3>
<div class="methodsynopsis dc-description">
<span class="type">int</span> <span class="methodname"><b>ignore_user_abort</b></span>
([ <span class="methodparam"><span class="type">string</span> <tt class="parameter">$value</tt></span>
] )</div>
<p class="para rdfs-comment">
Sets whether a client disconnect should cause a script to be aborted.
</p>
</div>
<a name="function.ignore-user-abort.parameters"></a><div class="refsect1 parameters">
<h3 class="title">Parameters</h3>
<p class="para">
</p><dl>
<dt class="varlistentry">
<span class="term"><i><tt class="parameter">value</tt></i>
</span>
</dt><dd class="listitem">
<p class="para">
If set, this function will set the <a href="misc.configuration.php#ini.ignore-user-abort" class="link">ignore_user_abort</a> ini setting
to the given <i><tt class="parameter">value</tt></i>
. If not, this function will
only return the previous setting without changing it.
</p>
</dd>
</dl>
<p>
</p>
</div>
<a name="function.ignore-user-abort.returnvalues"></a><div class="refsect1 returnvalues">
<h3 class="title">Return Values</h3>
<p class="para">
Returns the previous setting, as an integer.
</p>
</div>
<a name="function.ignore-user-abort.examples"></a><div class="refsect1 examples">
<h3 class="title">Examples</h3>
<p class="para">
</p><div class="example">
<p><b>Example #1 A <b>ignore_user_abort()</b> example</b></p>
<div class="example-contents programlisting">
<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>
</p>
</div>
<a name="function.ignore-user-abort.notes"></a><div class="refsect1 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
<a href="function.flush.php" class="function">flush()</a>.
</p>
</div>
<a name="function.ignore-user-abort.seealso"></a><div class="refsect1 seealso">
<h3 class="title">See Also</h3>
<p class="para">
</p><ul class="simplelist">
<li class="member"><a href="function.connection-aborted.php" class="function" rel="rdfs-seeAlso">connection_aborted()</a> - Check whether client disconnected</li>
<li class="member"><a href="function.connection-status.php" class="function" rel="rdfs-seeAlso">connection_status()</a> - Returns connection status bitfield</li>
<li class="member">
<a href="features.connection-handling.php" class="link">Connection Handling</a>
for a complete description of connection handling in PHP.
</li>
</ul><p>
</p>
</div>
</div><?php manual_footer(); ?>