Search code examples
phpexecution

PHP open files?


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.


Solution

  • 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.