0

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.

1
  • 1
    If either of those files uses sessions, be careful to session_write_close() in both of them before doing the long duration work. PHP's standard file-based sessions lock the session file upon session_start() and will not release it until you close the session or the script ends. That would mean only the first of the pages hit would run, and the other would wait until the first terminates/completes. Commented Aug 11, 2010 at 12:52

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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

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.

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.