php-doc-en/reference/misc/functions/ignore-user-abort.xml
Thomas Punt 158ca973fb Fixes bug #71107
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@338301 c90b9560-bf6c-de11-be94-00142212c4b1
2015-12-18 17:21:47 +00:00

140 lines
3.6 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<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>bool</type><parameter>value</parameter></methodparam>
</methodsynopsis>
<para>
Sets whether a client disconnect should cause a script to be aborted.
</para>
<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
<parameter>value</parameter> is set to &true;
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>value</parameter></term>
<listitem>
<para>
If set, this function will set the <link
linkend="ini.ignore-user-abort">ignore_user_abort</link> ini setting
to the given <parameter>value</parameter>. If not, this function will
only return the previous setting without changing it.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the previous setting, as an integer.
</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:"~/.phpdoc/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
-->