简体   繁体   中英

Stop PHP function after a certain time limit

I am developing a web service where I need to call an Oracle procedure in PHP. The Oracle procedure will take time to process and after completion it will write in a table.

How do I return an error in the web service response if the procedure call is taking too much time?

Note: I am stuck with PHP 5.2 and I cannot install cURL.

Did you consider using http://php.net/manual/en/function.set-time-limit.php ?

Sets the number of seconds a script is allowed to run. If this is reached, the script returns a fatal error. The default limit is 30 seconds or, if it exists, the max_execution_time value defined in the php.ini.

You can set it for your specific script for less than 30s, so it stops after eg a few seconds. And then you just handle empty response / error response.

在php.ini中,默认执行时间限制为30秒...对其进行自定义并在try catch中编写代码,并使用自定义错误消息处理异常。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM