<?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 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.register-tick-function.php',
    1 => 'register_tick_function',
    2 => 'Register a function for execution on each tick',
  ),
  'up' => 
  array (
    0 => 'ref.funchand.php',
    1 => 'Function handling Functions',
  ),
  'prev' => 
  array (
    0 => 'function.register-shutdown-function.php',
    1 => 'register_shutdown_function',
  ),
  'next' => 
  array (
    0 => 'function.unregister-tick-function.php',
    1 => 'unregister_tick_function',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/funchand/functions/register-tick-function.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.register-tick-function" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">register_tick_function</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.3, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">register_tick_function</span> &mdash; <span class="dc-title">Register a function for execution on each tick</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.register-tick-function-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">function</span> <span class="methodname"><strong>register_tick_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.boolean.php" class="type bool">bool</a></span></div>

  <p class="simpara">
   Registers the given <code class="parameter">callback</code> to be executed when a
   <a href="control-structures.declare.php#control-structures.declare.ticks" class="link">tick</a> is called.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.register-tick-function-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">callback</code></dt>
     <dd>
      <p class="para">
       The function to register.
      </p>
     </dd>
    
    
     <dt><code class="parameter">args</code></dt>
     <dd>
      <p class="para">
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.register-tick-function-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> on success or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> on failure.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.register-tick-function-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.5.0</td>
      <td>
       Tick handlers are now deactivated later during request shutdown: after
       all shutdown functions and destructors have run, and after the output
       handlers have been cleaned up. Previously they were deactivated at the
       very beginning of request shutdown, so tick functions were no longer
       called during shutdown functions, destructors, or output handling. See
       <a href="migration85.incompatible.php#migration85.incompatible.core.tick-handlers" class="link">the
       migration guide</a> for details.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.register-tick-function-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>register_tick_function()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><code style="color: #000000"><span style="color: #0000BB">&lt;?php
</span><span style="color: #007700">declare(</span><span style="color: #0000BB">ticks</span><span style="color: #007700">=</span><span style="color: #0000BB">1</span><span style="color: #007700">);

function </span><span style="color: #0000BB">my_tick_function</span><span style="color: #007700">(</span><span style="color: #0000BB">$param</span><span style="color: #007700">) {
    echo </span><span style="color: #DD0000">"Tick callback function called with param: </span><span style="color: #0000BB">$param</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;
}

</span><span style="color: #0000BB">register_tick_function</span><span style="color: #007700">(</span><span style="color: #DD0000">'my_tick_function'</span><span style="color: #007700">, </span><span style="color: #0000BB">true</span><span style="color: #007700">);
</span><span style="color: #0000BB">?&gt;</span></code></pre></div>
    </div>

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


 <div class="refsect1 seealso" id="refsect1-function.register-tick-function-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><a href="control-structures.declare.php" class="link">declare</a></li>
    <li><span class="function"><a href="function.unregister-tick-function.php" class="function" rel="rdfs-seeAlso">unregister_tick_function()</a> - De-register a function for execution on each tick</span></li>
   </ul>
  </p>
 </div>


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