I need my script to echo something while processing. But everything I echo after the the creation of the phpexcel object goes to buffer and only echoes after the script is finished.
Is there a workaround on this?
Here is some part of the code:
$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>";
Already tried ob_flush()
and flush()
after the echos, but neither of them works.
Tried everything here also: How to flush output after each `echo` call?
I need it to make a COMET solution, and if i can't output the echos right away, there is no way to achieve it.
Any ideas on how to make the script talk to javascript without outputting echos during its process would be welcome!