Php 通过exec传递长字符串

Php 通过exec传递长字符串,php,exec,Php,Exec,当我尝试传递一个短字符串时,它会传递,而当我尝试传递一个长字符串时,它不会传递 以下是我使用的代码: index.php function bgExec($cmd) { if(substr(php_uname(), 0, 7) == "Windows"){ pclose(popen("start /B ". $cmd, "r")); }else { exec($cmd . " > /dev/null &"); } } $string = "some long s

当我尝试传递一个短字符串时,它会传递,而当我尝试传递一个长字符串时,它不会传递

以下是我使用的代码:

index.php

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

$string = "some long string";

bgExec("php -q process.php $string");
process.php

file_put_contents('file.txt', print_r($argv[1], true));

有没有传递更长字符串的解决方案?

对于长数据,请使用管道,或者只提供输入数据的路径。

您只知道如何向下投票:/t尝试帮助而不是向下投票我不明白,请解释更多^^