What defines the timeout period in PHP?

扶醉桌前 提交于 2019-12-13 06:27:32

问题


Say, I have PHP running on an Apache. When someone makes a client request (doesn't matter how), what defines the amount of time that the client will wait for, the script to run? Is this option of an Apache, of a PHP or is defined by the client himself? Also, what if the script is called via curl?


回答1:


See PHP set_time_limit()

Set 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.

Please note:

This function has no effect when PHP is running in safe mode. There is no workaround other than turning off safe mode or changing the time limit in the php.ini.

You might also be interested in max_input_time (set via php.ini)

This sets the maximum time in seconds a script is allowed to parse input data, like POST and GET. It is measured from the moment of receiving all data on the server to the start of script execution.




回答2:


It's defined in php.ini, parameter is called max_execution_time.

You can change it with set_time_limit, ini_set OR in php.ini directly.

But, in fact you are asking about

the amount of time that the client will wait for, the script to run

and imho, it is infinite. I have never seen such a moment when server was running script and browser refused to wait. The main is to keep script running on server.



来源:https://stackoverflow.com/questions/13572099/what-defines-the-timeout-period-in-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!