proc_open()関数を使用してプロセスを実行しようとしています。ページで指定されているように、カスタム環境変数を指定して印刷しようとしました。提供されたすべての変数 + 常に 3 つの変数 (「SHLVL」、「PWD」、「_=」) が表示されます。提供された環境変数のみを印刷/使用したいと思います。これらの 3 つは常にこの関数に存在しますか? 変数のみを提供する方法はありますか? これはすべて Linux と PHP5 の下にあります。
//Here is the code to clarify :
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file to write to
);
$env = array('MY_VAR' => 'FOO');
$process = proc_open('./run.php', $descriptorspec, $pipes, $cwd, $env);
if (is_resource($process)) {
fwrite($pipes[0], escapeshellcmd($args));
fclose($pipes[0]);
$output = "";
while (!feof($pipes[1])) {
$output .= fgets($pipes[1]);
}
print "Output is $output \n";
fclose($pipes[1]);
$return_value = proc_close($process);
}
ありがとう。