1

From PHP manual: PHP_OUTPUT_HANDLER_CLEANABLE const control access to functions: ob_clean(), ob_end_clean(), and ob_get_clean().

ob_start(null, 0, PHP_OUTPUT_HANDLER_CLEANABLE);

Using ob_end_clean(), there is a notice: "ob_end_clean(): failed to discard buffer of default output handler (1)".

Using ob_get_clean(), there is even a double notice: "ob_get_clean(): failed to delete buffer of default output handler (1)".

I understand, that only cleanable buffer can't be flush and delete. So why in manual these functions are under control PHP_OUTPUT_HANDLER_CLEANABLE const? I'm confused about using flags in output buffering.

1
  • Which php version you use? Commented Feb 22, 2014 at 11:57

1 Answer 1

6

Passing only PHP_OUTPUT_HANDLER_CLEANABLE as arg means ob can only be cleaned, not flushed or removed (ended). ob_end_clean() tries to remove (end) the buffer but flag PHP_OUTPUT_HANDLER_REMOVABLE not passed so this is reason for the error. ob_get_clean() essentially executes both ob_get_contents() and ob_end_clean() so also error.

Passing only PHP_OUTPUT_HANDLER_FLUSHABLE as arg means ob can only be flushed, not cleaned or removed (ended).

Passing only PHP_OUTPUT_HANDLER_REMOVABLE as arg means ob can only be removed (ended), not cleaned or flushed.

Passing (PHP_OUTPUT_HANDLER_CLEANABLE | PHP_OUTPUT_HANDLER_FLUSHABLE) as arg means ob can only be cleaned and flushed, not removed (ended).

Passing (PHP_OUTPUT_HANDLER_CLEANABLE | PHP_OUTPUT_HANDLER_FLUSHABLE | PHP_OUTPUT_HANDLER_REMOVABLE) as arg means ob can be cleaned and flushed and removed (ended).

Similar result for all other combinations except note that PHP_OUTPUT_HANDLER_STDFLAGS is short for, or same as, (PHP_OUTPUT_HANDLER_CLEANABLE | PHP_OUTPUT_HANDLER_FLUSHABLE | PHP_OUTPUT_HANDLER_REMOVABLE).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.