<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >set_time_limit</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="PHP 手册" HREF="index.html"><LINK REL="UP" TITLE="PHP Options&Information" HREF="ref.info.html"><LINK REL="PREVIOUS" TITLE="set_magic_quotes_runtime" HREF="function.set-magic-quotes-runtime.html"><LINK REL="NEXT" TITLE="sys_get_temp_dir" HREF="function.sys-get-temp-dir.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP 手册</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.set-magic-quotes-runtime.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.sys-get-temp-dir.html" ACCESSKEY="N" >下一页</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.set-time-limit" ></A >set_time_limit</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN182470" ></A ><P > (PHP 3, PHP 4, PHP 5)</P >set_time_limit -- Limits the maximum execution time</DIV ><DIV CLASS="refsect1" ><A NAME="AEN182473" ></A ><H2 >说明</H2 >void <B CLASS="methodname" >set_time_limit</B > ( int seconds )<BR ></BR ><P > 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 <TT CLASS="literal" >max_execution_time</TT > value defined in the <TT CLASS="filename" >php.ini</TT >. </P ><P > When called, <B CLASS="function" >set_time_limit()</B > 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 <TT CLASS="literal" >set_time_limit(20)</TT > is made, the script will run for a total of 45 seconds before timing out. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN182487" ></A ><H2 >参数</H2 ><P > <P ></P ><DIV CLASS="variablelist" ><DL ><DT ><CODE CLASS="parameter" >seconds</CODE ></DT ><DD ><P > The maximum execution time, in seconds. If set to zero, no time limit is imposed. </P ></DD ></DL ></DIV > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN182496" ></A ><H2 >返回值</H2 ><P > 无返回值。 </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN182499" ></A ><H2 >注释</H2 ><DIV CLASS="warning" ><P ></P ><TABLE CLASS="warning" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >警告</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P > This function has no effect when PHP is running in <A HREF="features.safe-mode.html#ini.safe-mode" >安全模式</A >. There is no workaround other than turning off safe mode or changing the time limit in the <TT CLASS="filename" >php.ini</TT >. </P ></TD ></TR ></TABLE ></DIV ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >注意: </B > The <B CLASS="function" >set_time_limit()</B > function and the configuration directive <A HREF="ref.info.html#ini.max-execution-time" >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 <A HREF="function.system.html" ><B CLASS="function" >system()</B ></A >, stream operations, database queries, etc. is not included when determining the maximum time that the script has been running. </P ></BLOCKQUOTE ></DIV ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN182510" ></A ><H2 >参见</H2 ><P > <P ></P ><TABLE BORDER="0" ><TBODY ><TR ><TD ><A HREF="ref.info.html#ini.max-execution-time" >max_execution_time</A ></TD ></TR ><TR ><TD ><A HREF="ref.info.html#ini.max-input-time" >max_input_time</A ></TD ></TR ></TBODY ></TABLE ><P ></P > </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.set-magic-quotes-runtime.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >起始页</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.sys-get-temp-dir.html" ACCESSKEY="N" >下一页</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >set_magic_quotes_runtime</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.info.html" ACCESSKEY="U" >上一级</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >sys_get_temp_dir</TD ></TR ></TABLE ></DIV ></BODY ></HTML >