set_time_limit

void set_time_limit(int seconds); 

Sets the maximum script execution time.

Returns:

void

Description:

Specifies how long the script can run, in seconds. A useful function for avoiding infinite loops or connection timeouts to sockets or databases. The default time limit is 30 seconds or the value of max_execution_time, which can be specified in the PHP initialization file. A zero (0) value means that the script will not time out at all.

Example:

Set timeout to 60 seconds
// script dies after 60 secs 
set_time_limit(60);<scripts;execution time;configuring> 

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.