开发者

concurrency and PHP scripts

开发者 https://www.devze.com 2023-01-24 21:59 出处:网络
I\'m trying to fire a php script inside another php script. This is easy, the problem is that the first script can not wait for the second to finish.

I'm trying to fire a php script inside another php script. This is easy, the problem is that the first script can not wait for the second to finish. I want a fire and go mechanism.

Any help would be appreciated,

Than开发者_如何学JAVAks in advance.


From exec documentation:

If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP to hang until the execution of the program ends.

That is, the following should work:

exec("php /path.to.file.php > /dev/null");


You would have to use exec()

On your server / Operating system add the php/bin directory to your environment variables and then execute the command like so:

<?php
    //Blah

    exec("php /path.to.file.php /dev/null");

    //Blah
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消