How can the set_time_limit() function be used effectively to adjust script execution time?

The set_time_limit() function in PHP can be used to adjust the maximum execution time of a script. This is useful when you need to prevent long-running scripts from consuming excessive server resources or causing timeouts. By setting a specific time limit for script execution, you can control how long a script can run before it is terminated.

// Set the maximum execution time for the script to 30 seconds
set_time_limit(30);

// Your script code here