tags:

views:

49

answers:

3

current.php is page which we open in browser.

other_1.php and other_2.php are pages, which we want to execute. These two pages do a big job and work slowly.

How can we call both other pages to work, just when we open current.php?

current.php should just open and die, nothing get, just send commands to open.

If current page will include other pages, it will eat a lot of memory and go out from the maximum time execution available on hosting-account.

All the pages placed in same folder.

Any idea?

Thanks.

A: 

You can use

<?php

include("other_1.php");

?>

and at the end of other_1.php add another include for other_2.php, and so on. If I have misunderstood the question, let me know.

Liam Spencer
>If current page will include other pages, it will eat a lot of memory and go out from the maximum time execution available on hosting-account.
Happy
+1  A: 

you can try this one:

function execInBackground($cmd) {
    if (substr(php_uname(), 0, 7) == "Windows"){
        pclose(popen("start /B ". $cmd, "r")); 
    }
    else {
        exec($cmd . " > /dev/null &");  
    }
}

In the $cmd you pass the path to php and than you can use the command as in CLI.

VeeWee
What does this code do?
Happy
It executes a command (or a process) like when typing something into bash or cmd, but this function can be disabled on your web server due to security restrictions.
Emiswelt
its ok for unix servers?
Happy
normally it is, unless it's disabled. You can check this like:function exec_enabled() { $disabled = explode(', ', ini_get('disable_functions')); return !in_array('exec', $disabled);}$cmd can look like:/usr/bin/php -f /home/file.php
VeeWee
+1  A: 

You could have a look at this question:

http://stackoverflow.com/questions/124462/asynchronous-php-calls

It seems like this is exactly what you want.

Emiswelt