如何将参数传递给PHP exec()

时间:2015-03-12 07:47:04

标签: php exec

我使用以下代码在后台运行该功能。

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

$cmd = execInBackground("http://example.com/parentdesc/frontend/web/index.php?r=site%2Ftest");

工作正常。但是如何将参数传递给exec?

我试过了:

$cmd = execInBackground("http://example.com/parentdesc/frontend/web/index.php?r=site%2Ftest \"param1\" \"param2\" ");

在我的函数中,我打印$ argv。但它没有任何价值。

我的功能:

public function actionTest()
{
    // does not have anything           
    print_r($argv);
   // here is my mail sending logic
}

我错过了什么吗?

0 个答案:

没有答案