php-doc-en/reference/misc/functions/ignore-user-abort.xml
2009-02-28 19:14:14 +00:00

131 lines
3.1 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.10 $ -->
<refentry xml:id="function.ignore-user-abort" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>ignore_user_abort</refname>
<refpurpose>Set whether a client disconnect should abort script execution</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>int</type><methodname>ignore_user_abort</methodname>
<methodparam choice="opt"><type>string</type><parameter>setting</parameter></methodparam>
</methodsynopsis>
<para>
Sets whether a client disconnect should cause a script to be aborted.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>setting</parameter></term>
<listitem>
<para>
If not set, the function will only return the current setting.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the previous setting, as a boolean.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>A <function>ignore_user_abort</function> example</title>
<programlisting role="php">
<![CDATA[
<?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.
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<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
<function>flush</function>.
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>connection_aborted</function></member>
<member><function>connection_status</function></member>
<member>
<link linkend="features.connection-handling">Connection Handling</link>
for a complete description of connection handling in PHP.
</member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->