Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 6093

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!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>Register a function for execution on shutdown</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.get-defined-functions.html">get_defined_functions</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.register-tick-function.html">register_tick_function</a></div>
 <div class="up"><a href="ref.funchand.html">Function handling Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.register-shutdown-function" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">register_shutdown_function</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">register_shutdown_function</span> &mdash; <span class="dc-title">Register a function for execution on shutdown</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.register-shutdown-function-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><span class="type void">void</span></span> <span class="methodname"><strong>register_shutdown_function</strong></span>
    ( <span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>
   [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$parameter</code></span>
   [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$...</code></span>
  ]] )</div>

  <p class="para rdfs-comment">
   Registers a <code class="parameter">callback</code> to be executed after script
   execution finishes or <span class="function"><a href="function.exit.html" class="function">exit()</a></span> is called.
  </p>
  <p class="para">
   Multiple calls to <span class="function"><strong>register_shutdown_function()</strong></span> can be
   made, and each will be called in the same order as they were registered.
   If you call <span class="function"><a href="function.exit.html" class="function">exit()</a></span> within one registered shutdown
   function, processing will stop completely and no other registered
   shutdown functions will be called.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.register-shutdown-function-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">callback</code></dt>

     <dd>

      <p class="para">
       The shutdown callback to register.
      </p>
      <p class="para">
       The shutdown callbacks are executed as the part of the request, so
       it&#039;s possible to send output from them and access output buffers.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">parameter</code></dt>

     <dd>

      <p class="para">
       It is possible to pass parameters to the shutdown function by passing
       additional parameters.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">...</code></dt>

     <dd>

      <p class="para">
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.register-shutdown-function-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   No value is returned.
  </p>
 </div>

 
 <div class="refsect1 errors" id="refsect1-function.register-shutdown-function-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <p class="para">
   If the passed callback is not callable a <strong><code>E_WARNING</code></strong>
   level error will be generated.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.register-shutdown-function-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-6338">
    <p><strong>Example #1 <span class="function"><strong>register_shutdown_function()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">shutdown</span><span style="color: #007700">()<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;This&nbsp;is&nbsp;our&nbsp;shutdown&nbsp;function,&nbsp;in&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;here&nbsp;we&nbsp;can&nbsp;do&nbsp;any&nbsp;last&nbsp;operations<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;before&nbsp;the&nbsp;script&nbsp;is&nbsp;complete.<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">'Script&nbsp;executed&nbsp;with&nbsp;success'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">register_shutdown_function</span><span style="color: #007700">(</span><span style="color: #DD0000">'shutdown'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.register-shutdown-function-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    Working directory of the script can change inside the shutdown function
    under some web servers, e.g. Apache.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    Shutdown functions will not be executed if the process is killed with a SIGTERM
    or SIGKILL signal. While you cannot intercept a SIGKILL, you can use <span class="function"><a href="function.pcntl-signal.html" class="function">pcntl_signal()</a></span>
    to install a handler for a SIGTERM which uses <span class="function"><a href="function.exit.html" class="function">exit()</a></span> to
    end cleanly.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.register-shutdown-function-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><a href="ini.core.html#ini.auto-append-file" class="link">auto_append_file</a></li>
    <li class="member"><span class="function"><a href="function.exit.html" class="function" rel="rdfs-seeAlso">exit()</a> - Output a message and terminate the current script</span></li>
    <li class="member">The section on <a href="features.connection-handling.html" class="link">connection handling</a></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.get-defined-functions.html">get_defined_functions</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.register-tick-function.html">register_tick_function</a></div>
 <div class="up"><a href="ref.funchand.html">Function handling Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>