uTools-Manuals/docs/php/set_time_limit.html
2019-04-08 23:22:26 +08:00

88 lines
3.8 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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>设置脚本最大执行时间</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><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)</p><p class="refpurpose"><span class="refname">set_time_limit</span> &mdash; <span class="dc-title">设置脚本最大执行时间</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.set-time-limit-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>set_time_limit</strong></span>
( <span class="methodparam"><span class="type">int</span> <code class="parameter">$seconds</code></span>
) : <span class="type">bool</span></div>
<p class="para rdfs-comment">
设置允许脚本运行的时间单位为秒。如果超过了此设置脚本返回一个致命的错误。默认值为30秒或者是在<var class="filename">php.ini</var><em>max_execution_time</em>被定义的值,如果此值存在。
</p>
<p class="para">
当此函数被调用时,<span class="function"><strong>set_time_limit()</strong></span>会从零开始重新启动超时计数器。换句话说如果超时默认是30秒在脚本运行了了25秒时调用 <em>set_time_limit(20)</em>那么脚本在超时之前可运行总时间为45秒。
</p>
</div>
<div class="refsect1 parameters" id="refsect1-function.set-time-limit-parameters">
<h3 class="title">参数</h3>
<p class="para">
<dl>
<dt>
<code class="parameter">seconds</code></dt>
<dd>
<p class="para">
最大的执行时间单位为秒。如果设置为0没有时间方面的限制。
</p>
</dd>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.set-time-limit-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
成功时返回 <strong><code>TRUE</code></strong>,失败时返回 <strong><code>FALSE</code></strong>
</p>
</div>
<div class="refsect1 notes" id="refsect1-function.set-time-limit-notes">
<h3 class="title">注释</h3>
<div class="warning"><strong class="warning">Warning</strong>
<p class="para">
当php运行于<a href="ini.sect.safe-mode.html#ini.safe-mode" class="link">安全模式</a>时,此功能不能生效。除了关闭安全模式或改变<var class="filename">php.ini</var>中的时间限制,没有别的办法。
</p>
</div>
<blockquote class="note"><p><strong class="note">Note</strong>:
<p class="para">
<span class="function"><strong>set_time_limit()</strong></span>函数和配置指令<a href="info.configuration.html#ini.max_execution_time" class="link">max_execution_time</a>只影响脚本本身执行的时间。任何发生在诸如使用<span class="function"><a href="system.html" class="function">system()</a></span>的系统调用流操作数据库操作等的脚本执行的最大时间不包括其中当该脚本已运行。在测量时间是实值的Windows中情况就不是如此了。
</p>
</p></blockquote>
</div>
<div class="refsect1 seealso" id="refsect1-function.set-time-limit-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><a href="info.configuration.html#ini.max-execution-time" class="link">max_execution_time</a></li>
<li class="member"><a href="info.configuration.html#ini.max-input-time" class="link">max_input_time</a></li>
</ul>
</p>
</div>
</div></div></div></body></html>