否,exec
將運行完成,然後纔會將結果存儲在會話中。
您應該運行一個子進程直接寫入一個文件,然後讀取該文件在您的瀏覽器:
$path = tempnam(sys_get_temp_dir(), 'myscript');
$_SESSION['work_path'] = $path;
// Release session lock
session_write_close();
$process = proc_open(
'my shell command',
[
0 => ['pipe', 'r'],
1 => ['file', $path],
2 => ['pipe', 'w'],
],
$pipes
);
if (!is_resource($process)) {
throw new Exception('Failed to start');
}
fclose($pipes[0]);
fclose($pipes[2]);
$return_value = proc_close($process);
在你follow.php
然後你可以只輸出電流輸出:
echo file_get_contents($_SESSION['work_path']);