Title: PHP output buffering
Last modified: August 18, 2016

---

# PHP output buffering

 *  [schvenk](https://wordpress.org/support/users/schvenk/)
 * (@schvenk)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/php-output-buffering/)
 * I’m trying to use PHP output buffering with WordPress and am running into trouble.
 * Initially I had my server configured to run a PHP script before and after WordPress
   via auto_prepend_file and register_shutdown_function. The prepend script called
   ob_start, and the shutdown function called ob_get_contents(). Turns out, however,
   that PHP won’t let you work with output buffers in a shutdown function…the contents
   are flushed before the function is called.
 * The other option is to call an append script via auto_append_file. This works,
   except that I have to edit the WordPress installation’s template-loader.php file
   and eliminate all its calls to exit(). So far that doesn’t seem to break anything,
   but I’d rather not edit my WordPress install, since that complicates updates 
   and such. Any suggestions?

Viewing 1 replies (of 1 total)

 *  [Jon Bourne](https://wordpress.org/support/users/akbigdog/)
 * (@akbigdog)
 * [19 years, 6 months ago](https://wordpress.org/support/topic/php-output-buffering/#post-340500)
 * Can anyone offer insight as to why removing all calls to `exit()` in template_loader.
   php is necessary? Or why they are there in first place?
 * I am running into this same problem. I would like to wrap my caching system into
   a plugin, both to ease upgrades and so that others may use it, but I can’t get
   over this one hurdle.

Viewing 1 replies (of 1 total)

The topic ‘PHP output buffering’ is closed to new replies.

## Tags

 * [buffer](https://wordpress.org/support/topic-tag/buffer/)
 * [output](https://wordpress.org/support/topic-tag/output/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 1 reply
 * 2 participants
 * Last reply from: [Jon Bourne](https://wordpress.org/support/users/akbigdog/)
 * Last activity: [19 years, 6 months ago](https://wordpress.org/support/topic/php-output-buffering/#post-340500)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
