Link to home
Start Free TrialLog in
Avatar of Borsec
BorsecFlag for Romania

asked on

php timeout handle

I have 2 php scripts:
script for test1.php:
<?php
require_once("test2.php");
ini_set(max_execution_time,300);

$objectC = new C();
$objectC->funcC();
?>

script for test2.php:
<?php
class C
{
 function funcC()
 {
    //do something that needs at most 5 minutes to execute !!!!!
 }
}
?>
My problem is that the script will end after 30 seconds with timeout error even if I write ini_set(max_execution_time,300);
I run the script in this way: http:// localhost / test1.php in IE browser
What am I doing wrong experts?
ASKER CERTIFIED SOLUTION
Avatar of davekok
davekok
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Borsec

ASKER

When using the set_time_limit() function, the browser will stop after about 30 seconds if it does not get new data. To prevent this, you can send every 10 seconds a little snippet of data (like a single character) to the browser. The code below is tested with both Internet Explorer and Firefox, so it will stay online all the time.
Avatar of Borsec

ASKER

if you send some data every 10 seconds to the browser you dont need set_time_limit().