Controlling the execution time of a PHP script using a server language is important for testing and optimizing the data processing algorithm. In fact, the server language provides the site, but does not control it. A browser works with the visitor, which is JavaScript, HTML tags, and CSS rules. However, correctly preparing the page and files for the browser to work is PHP's concern.
PHP script runtime
Thirty seconds is given to any script to do the work, unless otherwise specified in the php.ini file in the max_execution_time directive. This parameter can be changed in the initialization file and in the script code.
The PHP function set_time_limit (0) makes the script infinite. Any value other than zero sets a time limit, which is set in seconds.
In most tasks, controlling the execution time is important in the process of testing algorithms for solving volumetric tasks (a lot of data, complex processes, unstable or slow data sources) or code containing many conditions and cycles.
In reality, in run mode, use the PHP runtime limit set_time_limit () function - a rule of good form, but no more. As a server-side language, PHP is fast and efficient. Time delays can be caused by databases and other external factors. There are not many algorithms that are destined to process large and voluminous data.
On the security and stability of the site
If the site is built on the basis of the popular site management system, uses external JS libraries, for example, jQuery and data transfer via AJAX, there is an external uncertainty factor.
It was one thing when the developer wrote the server code (PHP) itself and the site functionality (HTML, CSS, JavaScript). It is quite another matter when the management systematically goes into the bowels of the CMS or to a remote server of an external API (library, template, framework).
Whether or not to use the PHP function set_time_limit () is a matter of preference for the developer, but if there are external factors, managing the execution time of the work on the server is the key to the security and stability of the resource.
You can always interrupt a process that is too protracted and not annoy the visitor with delays in fulfilling his desires.