There are two options:
1.
set_time_limit
set the maximum execution time for the current script without altering the php.ini file. The change is temporary and applies only to the current script.
set_time_limit(300); // 5 minutes
init_set
modifies the max_execution_time
directive in the php.ini file, affecting all PHP pages using this configuration. As described in the documentation "The configuration option will keep this new value during the script's execution, and will be restored at the script's ending".
ini_set('max_execution_time', 300); // 5 minutes
Both functions limit the execution time of a PHP script, but set_time_limit
affects only the current script, while ini_set
influences all PHP pages using the configuration directive.