您可以proc_open
将此文件作为参数使用和调用 PHP 解释器。这不会将数据存储在内存中,但会创建另一个进程。
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("file", $path, "w"), // stdout is a pipe that the child will write to
2 => array("file", $path, "a") // stderr is a file to write to
);
$process = proc_open('php dynamic_data.php', $descriptorspec, $pipes);
if (is_resource($process)) {
// $pipes now looks like this:
// 0 => writeable handle connected to child stdin
// 1 => readable handle connected to child stdout
// Any error output will be appended to /tmp/error-output.txt
fclose($pipes[0]);
fclose($pipes[1]);
$return_value = proc_close($process);
}
?>