Last active
October 19, 2017 07:02
-
-
Save nextend/eb062de0ac2f077b7156170fb10f4084 to your computer and use it in GitHub Desktop.
Before you want to send files or structured data over and AJAX call from PHP you might need to clean all output buffers (ob_start(...)) to be able to trash the junk in the buffers. It especially can happen in CMS like Joomla, WordPress etc.. when other plugin does strange things.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function ob_end_clean_all() { | |
$handlers = ob_list_handlers(); | |
while (count($handlers) > 0 && $handlers[count($handlers) - 1] != 'ob_gzhandler' && $handlers[count($handlers) - 1] != 'zlib output compression') { | |
ob_end_clean(); | |
$handlers = ob_list_handlers(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment