<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.funchand.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'function.register-shutdown-function.php',
    1 => 'register_shutdown_function',
    2 => 'Register a function for execution on shutdown',
  ),
  'up' => 
  array (
    0 => 'ref.funchand.php',
    1 => 'Function handling Funzioni',
  ),
  'prev' => 
  array (
    0 => 'function.get-defined-functions.php',
    1 => 'get_defined_functions',
  ),
  'next' => 
  array (
    0 => 'function.register-tick-function.php',
    1 => 'register_tick_function',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/funchand/functions/register-shutdown-function.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<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, PHP 8)</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">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>register_shutdown_function</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>, <span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">...$args</code></span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></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.php" 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.php" class="function">exit()</a></span> within one registered shutdown
   function, processing will stop completely and no other registered
   shutdown functions will be called.
  </p>
  <p class="para">
   Shutdown functions may also call <span class="function"><strong>register_shutdown_function()</strong></span>
   themselves to add a shutdown function to the end of the queue.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.register-shutdown-function-parameters">
  <h3 class="title">Elenco dei parametri</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">args</code></dt>
     <dd>
      <p class="para">
       It is possible to pass parameters to the shutdown function by passing
       additional parameters.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.register-shutdown-function-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">
   Nessun valore viene restituito.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.register-shutdown-function-examples">
  <h3 class="title">Esempi</h3>
  <p class="para">
   <div class="example" id="example-1">
    <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 </span><span style="color: #0000BB">shutdown</span><span style="color: #007700">()<br />{<br />    </span><span style="color: #FF8000">// This is our shutdown function, in <br />    // here we can do any last operations<br />    // before the script is complete.<br /><br />    </span><span style="color: #007700">echo </span><span style="color: #DD0000">'Script executed with success'</span><span style="color: #007700">, </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">Note</h3>
  <blockquote class="note"><p><strong class="note">Nota</strong>: 
   <p class="para">
    The 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">Nota</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.php" class="function">pcntl_signal()</a></span>
    to install a handler for a SIGTERM which uses <span class="function"><a href="function.exit.php" class="function">exit()</a></span> to
    end cleanly.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Nota</strong>: 
   <p class="para">
    Shutdown functions run separately from the time tracked by
    <a href="info.configuration.php#ini.max-execution-time" class="link">max_execution_time</a>. That means
    even if a process is terminated for running too long, shutdown functions will still be
    called.  Additionally, if the <code class="literal">max_execution_time</code> runs out while
    a shutdown function is running it will not be terminated.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.register-shutdown-function-seealso">
  <h3 class="title">Vedere anche:</h3>
  <p class="para">
   <ul class="simplelist">
    <li><a href="ini.core.php#ini.auto-append-file" class="link">auto_append_file</a></li>
    <li><span class="function"><a href="function.exit.php" class="function" rel="rdfs-seeAlso">exit()</a> - Terminate the current script with a status code or message</span></li>
    <li><span class="function"><a href="function.fastcgi-finish-request.php" class="function" rel="rdfs-seeAlso">fastcgi_finish_request()</a> - Flushes all response data to the client</span></li>
    <li>The section on <a href="features.connection-handling.php" class="link">connection handling</a></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>