php timeout handle

Borsec
Borsec used Ask the Experts™
on
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?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Try using set_time_limit() (http://www.php.net/manual/en/function.set-time-limit.php). Please note that setting the time limit does not work when running in safe mode.

Author

Commented:
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.

Author

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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial