<HTML ><HEAD ><TITLE >set_time_limit</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" 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="version_compare" HREF="function.version-compare.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></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 Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.set-magic-quotes-runtime.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.version-compare.html" ACCESSKEY="N" >Next</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="AEN75325" ></A ><P > (PHP 3, PHP 4 )</P >set_time_limit -- Limits the maximum execution time</DIV ><DIV CLASS="refsect1" ><A NAME="AEN75328" ></A ><H2 >Description</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 <A HREF="ref.info.html#ini.max-execution-time" >configuration file</A >. If seconds is set to zero, no time limit is imposed. </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 set_time_limit(20) is made, the script will run for a total of 45 seconds before timing out. </P ><P > <B CLASS="function" >set_time_limit()</B > has no effect when PHP is running in safe mode. There is no workaround other than turning off safe mode or changing the time limit in the <A HREF="ref.info.html#ini.max-execution-time" >configuration file</A >. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </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 >, the <A HREF="function.sleep.html" ><B CLASS="function" >sleep()</B ></A > function, database queries, etc. is not included when determining the maximum time that the script has been running. </P ></BLOCKQUOTE ></DIV ></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" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.version-compare.html" ACCESSKEY="N" >Next</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" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >version_compare</TD ></TR ></TABLE ></DIV ></BODY ></HTML >