PHP ob_implicit_flush() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
Output Control

Definition

In PHP, ob_implicit_flush() turns automatic flush() behavior on or off after output is produced.

When enabled, PHP effectively calls flush() after blocks of output so you do not need as many explicit flush() calls. Despite the "ob_" name, it does not automatically call ob_flush() on user output buffers started with ob_start().

Syntax

Call ob_implicit_flush() with the values you need. Start with this line.

PHP
ob_implicit_flush(true);
CallWhat it does
ob_implicit_flush()Turns implicit flush on (default argument is true).
ob_implicit_flush(true)Same as the default: enable automatic flush().
ob_implicit_flush(false)Turns implicit flush off again.

This function returns void. Empty strings and header-only operations are not treated as output for implicit flushing. Effects are easiest to notice in long-running web responses; CLI and proxies may still delay what you see.

Library declarations
PHP
ob_implicit_flush(bool $enable = true): void

Parameters

ParameterDescription
enableOptional. true (default) turns implicit flushing on. false turns it off.

Return Value

Return ValueDescription
voidNo return value.

PHP Examples

Example 1 — Turn Implicit Flush On and Off

Enable and disable the setting. There is no return value, so the demo prints status labels you control.

PHP
<?php
ob_implicit_flush(true);
echo "implicit flush: on", PHP_EOL;
ob_implicit_flush(false);
echo "implicit flush: off", PHP_EOL;

How It Works

  1. ob_implicit_flush(true) enables automatic flush() behavior.
  2. We print a label while it is on.
  3. ob_implicit_flush(false) disables it.
  4. The second label confirms the script continued normally.

Example 2 — Still Needs ob_flush With ob_start

Start a user buffer, enable implicit flush, and show that buffered text stays until ob_flush().

PHP
<?php
ob_start();
ob_implicit_flush(true);
echo "buffered";
$before = ob_get_contents();
ob_flush();
$after = ob_get_contents();
ob_end_clean();
echo PHP_EOL, "before=", var_export($before, true), " after=", var_export($after, true), PHP_EOL;

How It Works

  1. ob_start() captures echo into a user buffer.
  2. ob_implicit_flush(true) does not empty that buffer by itself.
  3. ob_get_contents() still sees "buffered" before ob_flush().
  4. ob_flush() sends and clears the user buffer; then the copy is empty.

Example 3 — Default Argument Enables Flushing

Call ob_implicit_flush() with no arguments, which is the same as passing true.

PHP
<?php
ob_implicit_flush();
echo "default enable", PHP_EOL;
ob_implicit_flush(false);
echo "disabled again", PHP_EOL;

How It Works

  1. Calling ob_implicit_flush() with no args enables the feature.
  2. A short message is printed.
  3. Passing false turns the feature off.
  4. Another message prints after the setting change.

Frequently Asked Questions

It turns automatic flush() calls on or off after output is produced, so you may not need as many explicit flush() calls.
No. It relates to flush() (system write buffers), not to emptying an ob_start() user buffer.
true. Calling ob_implicit_flush() with no arguments turns implicit flushing on.
No. The signature is void.
For long streaming-style output where you want flush() often. If you use ob_start(), learn ob_flush() and flush() separately first.

Next: ob_list_handlers()

ob_list_handlers() returns an array of the names of every active output handler, from the .

ob_list_handlers() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful