note 98588 modified in function.ob-end-flush by danbrown
| From: | danbrown@php.net | Date: | Fri, 25 Jun 2010 13:32:18 +0000 |
| Subject: | note 98588 modified in function.ob-end-flush by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-170411@lists.php.net to get a copy of this message | ||
Wanted to speed things up and put some processing after the page has been delivered to the client.
That drove me almost insane, but finally, I found a solution (php 5.2.5):
<?php
ob_start(); // outer buffer
ob_start(); // inner buffer to catch URL rewrites and other post processing
session_start(); // registers URL rewriter with inner buffer!
echo '...';
// log performance data to log files *after* delivering the page!
register_shutdown_function(array($benchmarkclass,'log_perf_data'));
// now flush output output to client
ob_end_flush();
// need to calculate content length *after* URL rewrite!
header("Content-length: ".ob_get_length());
ob_end_flush();
// now we close the session and do some arbitrary clean-up tasks
// registered using register_shutdown_function()
session_write_close();
?>
--was--
Wanted to speed things up and put some processing after the page has been delivered to the client.
That drove me almost insane, but finally, I found a solution (php 5.2.5):
ob_start(); // outer buffer
ob_start(); // inner buffer to catch URL rewrites and other post processing
session_start(); // registers URL rewriter with inner buffer!
echo ...
// log performance data to log files *after* delivering the page!
register_shutdown_function(array($benchmarkclass,'log_perf_data'));
// now flush output output to client
ob_end_flush();
// need to calculate content length *after* URL rewrite!
header("Content-length: ".ob_get_length());
ob_end_flush();
// now we close the session and do some arbitrary clean-up tasks
// registered using register_shutdown_function()
session_write_close();
http://php.net/manual/en/function.ob-end-flush.php