Output Buffering Control
- Introduction
- Installing/Configuring
- Predefined Constants
- Examples
- Output Control Functions
- flush — Flush the output buffer
- ob_clean — Clean (erase) the output buffer
- ob_end_clean — Clean (erase) the output buffer and turn off output buffering
- ob_end_flush — Flush (send) the output buffer and turn off output buffering
- ob_flush — Flush (send) the output buffer
- ob_get_clean — Get current buffer contents and delete current output buffer
- ob_get_contents — Return the contents of the output buffer
- ob_get_flush — Flush the output buffer, return it as a string and turn off output buffering
- ob_get_length — Return the length of the output buffer
- ob_get_level — Return the nesting level of the output buffering mechanism
- ob_get_status — Get status of output buffers
- ob_gzhandler — ob_start callback function to gzip output buffer
- ob_implicit_flush — Turn implicit flush on/off
- ob_list_handlers — List all output handlers in use
- ob_start — Turn on output buffering
- output_add_rewrite_var — Add URL rewriter values
- output_reset_rewrite_vars — Reset URL rewriter values
- Alternative PHP Cache
- APCu
- Расширенный отладчик PHP
- PHP bytecode Compiler
- Blenc - BLowfish ENCoder for PHP source scripts
- Обработка и протоколирование ошибок
- htaccess-like support for all SAPIs
- Inclusion hierarchy viewer
- Memtrack
- OPcache
- Управление буфером вывода
- PHP Опции и Информация
- runkit
- Break the silence operator
- uopz
- Weak References
- Windows Cache for PHP
- Hierarchical Profiler
Коментарии
The manual is a little shy on explaining that output buffers are nested, and that "turns off output buffering" means turning off the highest nested buffer. See ob_get_level (for a useful function, but still no explanation)
<?php
ob_start();
echo "1:blah\n";
ob_start();
echo "2:blah";
// ob_get_clean() returns the contents of the last buffer opened. The first "blah" and the output of var_dump are flushed from the top buffer on exit
var_dump(ob_get_clean());
exit;
?>
puts:
1:blah
string(6) "2:blah"
Prior to realising this, I had thought PHP's ob functionality left more to be desired. I *really* wish I knew earlier.