如何在一段固定的时间后终止Php脚本

How do i make a Php script terminate after a fixed amount of time

Using the max_execution_time setting in PHP.

Ie:

ini_set('max_execution_time', 30);

Would end the script after 30 seconds of execution (this is default in PHP)

You could also use:

set_time_limit(30);

See: http://php.net/manual/en/function.set-time-limit.php and http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time

I would use the set_time_limit() function which specifies the amount of time a script is allowed to run after the point at which this function has been called.

More info here