【发布时间】:2015-10-21 12:07:35
【问题描述】:
我需要我的脚本在处理时回显某些内容。但是我在创建 phpexcel 对象后回显的所有内容都会进入缓冲区,并且只有在脚本完成后才会回显。
有解决办法吗?
以下是部分代码:
$inputFileName = 'index.xlsx';
echo "bla<br>";
// Read your Excel workbook
try {
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
echo "Hi<br>";
//Everything before here does not go to buffer.
$objPHPExcel = $objReader->load($inputFileName);
//Everything after here goes to buffer and only echoes after the script has finished running
echo "Hi<br>";
} catch (Exception $e) {
die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME)
. '": ' . $e->getMessage());
}
ob_implicit_flush(true);
ob_end_flush();
echo "Hi<br>";
在 echo 之后已经尝试过 ob_flush() 和 flush(),但它们都不起作用。
这里也试过了:How to flush output after each `echo` call?
我需要它来做一个 COMET 解决方案,如果我不能马上输出回声,就没有办法实现它。
欢迎任何关于如何使脚本与 javascript 对话而不在其过程中输出回声的想法!
【问题讨论】:
标签: php output buffer phpexcel output-buffering