dtqpw68806 2015-09-02 14:51 采纳率: 100%
浏览 9
已采纳

在for循环中执行 - 执行多个实例

How can you run multiple exec instances from a for loop and run them separately (i.e. not have one dependent on another finishing before starting another)? I have the following code which is hopefully self explanatory:

for ($i = 0;$i < 5;$i++){
    exec('START '.$path.' '.PATH.'spawn.php "'."$type,$core".'"');
}

I have looked at php in background exec() function but it isn't a duplicate as I am using the START command and adding an & did not fix it.

I have tried /B as an option but additionally this didn't work - it just ran it in the background.

  • 写回答

1条回答 默认 最新

  • doutan2111 2015-09-02 15:28
    关注

    Under windows you will need to do it a bit differently.

    $runCommand = 'calc.exe';
    $WshShell = new COM("WScript.Shell");
    $oExec = $WshShell->Run($runCommand, 7, false);
    

    This should help explain it http://www.somacon.com/p395.php

    http://de2.php.net/manual/en/function.exec.php#43917

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?