PHP Function Reference

PHP - Output Control



The Output Control functions allow you to control when output is sent from the script. This can be useful in several different situations, especially if you need to send headers to the browser after your script has begun outputting data. The Output Control functions do not affect headers sent using header() or setcookie(), only functions such as echo and data between blocks of PHP code.

Installation

There is no installation needed to use these functions. These functions are part of the PHP core.

PHP Output Control Functions

FunctionsDescription
ob_get_contents() Returns the contents of the output buffer.
ob_get_length() Returns the length of the output buffer.
ob_get_level() Returns the nesting level of the output buffering mechanism.
ob_start() Turns on output buffering.

PHP Output Control Predefined Constants

The constants below are always available as part of the PHP core.

ConstantsTypeDescription
PHP_OUTPUT_HANDLER_STARTIntegerIndicates that output buffering has begun.
PHP_OUTPUT_HANDLER_WRITEIntegerIndicates that the output buffer is being flushed, and had data to output.
PHP_OUTPUT_HANDLER_FLUSHIntegerIndicates that the buffer has been flushed.
PHP_OUTPUT_HANDLER_CLEANIntegerIndicates that the output buffer has been cleaned.
PHP_OUTPUT_HANDLER_FINALIntegerIndicates that this is the final output buffering operation.
PHP_OUTPUT_HANDLER_CONTIntegerIndicates that the buffer has been flushed, but output buffering will continue. This is an alias for PHP_OUTPUT_HANDLER_WRITE.
PHP_OUTPUT_HANDLER_ENDIntegerIndicates that output buffering has ended. This is an alias for PHP_OUTPUT_HANDLER_FINAL.
PHP_OUTPUT_HANDLER_CLEANABLEIntegerControls whether an output buffer created by ob_start() can be cleaned.
PHP_OUTPUT_HANDLER_FLUSHABLEIntegerControls whether an output buffer created by ob_start() can be flushed.
PHP_OUTPUT_HANDLER_REMOVABLEIntegerControls whether an output buffer created by ob_start() can be removed before the end of the script.
PHP_OUTPUT_HANDLER_STDFLAGSIntegerThe default set of output buffer flags; currently equivalent to PHP_OUTPUT_HANDLER_CLEANABLE | PHP_OUTPUT_HANDLER_FLUSHABLE | PHP_OUTPUT_HANDLER_REMOVABLE.

5