Search code examples
phpoutput-bufferingtruncation

Output from ob_get_clean() is truncated at 1024 characters?


I'm working on someone elses code and there is ~800 lines of markup mixed in with tags. I'm trying to apply some templates to these pages and I thought I would start by capturing all the output in an output buffer, return that as a variable and then sort things out piece by piece.

The problem is that at the end of the buffer when I return the output as a string it is truncated at 1024 characters. Why would this be?


Solution

  • Normally, it doesn't do that, which could mean:

    1. There is another ob_start($callback) with a specific callback active messing things up (what does ob_get_level say?).
    2. There is erroneous manipulation after the ob_get_clean()
    3. There are erroneous checking methods involved, and the 1024 cut-off is incorrect (xdebug's limit on var_dump's, hidden content in html-attributes & not looking at the source, etc.)

    Those 3 are about it, without code there isn't much else to say.