All values only appear after max_execution_time was reached.

Hey,
I am trying to get a value every x time,
Tthis works I get my value every time for my set time but only after the max execution time is reached.

Example:
[php]ini_set(‘max_execution_time’, 40); //40 sec[/php]

[php]function Loopvalue(){
sleep(10);// Set loop time for getprice_USDT_BTC
getprice_USDT_BTC();

return Loopvalue();

}

Loopvalue();[/php]

What this does, after the 40sec execution time I get a return of 4 prices but when I change the execution time to 0 for no limit the page stays blank.

Thanks for you time!

You don’t understand what max_execution_time actually does.

[url=http://php.net/manual/en/info.configuration.php#ini.max-execution-time]max_execution_time[/url] integer This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser. This helps prevent poorly written scripts from tying up the server. The default setting is 30. When running PHP from the command line the default setting is 0.

The maximum execution time is not affected by system calls, stream operations etc. Please see the set_time_limit() function for more details.

You can not change this setting with ini_set() when running in safe mode. The only workaround is to turn off safe mode or by changing the time limit in the php.ini.

Your web server can have other timeout configurations that may also interrupt PHP execution. Apache has a Timeout directive and IIS has a CGI timeout function. Both default to 300 seconds. See your web server documentation for specific details.

Web servers are not designed to output data this way. They are designed to accept a http(s) request and output a complete response to the device that made the request. When the server code ends execution, which it will do when the max execution time limit is reached, it completes the http response and sends any buffered output to the client. You can ‘try’ to make this work by flushing/satisfying all the buffering between the server and the client (php can buffer data, the web server can buffer data, any proxies in between can buffer data, and the browser can buffer data.)

To provide this type of data display using a web server, you need to use one of three methods -

  1. Short Polling - the client makes a series of timed requests to the web server and the web server outputs a response to the client, that might or might not contain new data.

  2. Long Polling - the client makes a single request to the web server and the web server loops until it has new data to output. When the new data is sent to the client, it uses it, then makes another request to the web server to start the process again.

  3. Web Sockets - an actual protocol designed to send data back and forth between the client/server.

See this link for more information - http://www.websocket.org/quantum.html

Sponsor our Newsletter | Privacy Policy | Terms of Service