PHP

  minte9
REMEMBERS




Last update:   29-10-2021

Ob_start()

It opens a buffer where the output is stored. Every time you do an echo, the output is added to that buffer. When you call ob_flush() the output is sent to the browser.
 
function callback($buffer) {
    return str_replace("apples", "bananas", $buffer);
}

ob_start("callback"); // Look Here

?>
    My string with apples and oranges.
<?php

ob_end_flush();

/**
    My string with bananas and oranges
**/
You have more control over the output.
 
ob_start();

$header = "UnitTests - %s <hr>";

echo "My tests passed ... <br>";
$passed = true;

echo "My tests 2 failed ... <br>";
$passed = false;

$output = ob_get_contents();
ob_end_clean();

$header = sprintf($header, $passed ? "Passed" : "Failed"); // Look Here
echo $header . $output;

/**
    UnitTests - Failed
    My tests passed ...
    My tests 2 failed ...
**/

Questions    
Object instantiation
        A B C D E F
🔔
1/1