Example 1 — Get the String and Flush
Capture and flush in one step, then print a label that includes the returned string.
<?php
ob_start();
echo "payload";
$s = ob_get_flush();
echo PHP_EOL, "returned=", $s, PHP_EOL; How It Works
- "payload" is buffered.
- ob_get_flush() returns "payload", sends it, and ends the buffer.
- You see "payload" from the flush itself.
- The next echo prints returned=payload using the variable.

