<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.info.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.set-time-limit.php',
    1 => 'set_time_limit',
    2 => 'Limits the maximum execution time',
  ),
  'up' => 
  array (
    0 => 'ref.info.php',
    1 => 'PHP Options/Info Functions',
  ),
  'prev' => 
  array (
    0 => 'function.set-include-path.php',
    1 => 'set_include_path',
  ),
  'next' => 
  array (
    0 => 'function.sys-get-temp-dir.php',
    1 => 'sys_get_temp_dir',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/info/functions/set-time-limit.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.set-time-limit" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">set_time_limit</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">set_time_limit</span> &mdash; <span class="dc-title">Limits the maximum execution time</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.set-time-limit-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>set_time_limit</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$seconds</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Set the number of seconds a script is allowed to run. If this is reached,
   the script returns a fatal error. The default limit is 30 seconds or, if
   it exists, the <code class="literal">max_execution_time</code> value defined in the
   <var class="filename">php.ini</var>.
  </p>
  <p class="para">
   When called, <span class="function"><strong>set_time_limit()</strong></span> restarts the timeout
   counter from zero. In other words, if the timeout is the default 30
   seconds, and 25 seconds into script execution a call such as
   <code class="literal">set_time_limit(20)</code> is made, the script will run for a
   total of 45 seconds before timing out.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.set-time-limit-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">seconds</code></dt>
     <dd>
      <p class="para">
       The maximum execution time, in seconds. If set to zero, no time limit
       is imposed.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.set-time-limit-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 notes" id="refsect1-function.set-time-limit-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    The <span class="function"><strong>set_time_limit()</strong></span> function and the configuration 
    directive <a href="info.configuration.php#ini.max-execution-time" class="link">max_execution_time</a>
    only affect the execution time of the script itself.  Any time spent on
    activity that happens outside the execution of the script such as system
    calls using <span class="function"><a href="function.system.php" class="function">system()</a></span>, stream operations, database
    queries, etc. is not included when determining the maximum time that the
    script has been running.
    This is not true on Windows where the measured time is real.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.set-time-limit-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><a href="info.configuration.php#ini.max-execution-time" class="link">max_execution_time</a></li>
    <li><a href="info.configuration.php#ini.max-input-time" class="link">max_input_time</a></li>
   </ul>
  </p>
 </div>


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