nix
nix

Reputation: 2285

What defines the timeout period in PHP?

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?

Upvotes: 0

Views: 333

Answers (2)

loler
loler

Reputation: 2587

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.

Upvotes: 0

maček
maček

Reputation: 77778

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.

Upvotes: 1

Related Questions