<?php
class X {
function test() {
ob_start(array($this, "display"));
//first test
?>
<html>
<body>
<p>It's like comparing apples to oranges.</p>
</body>
</html>
<?php
ob_end_flush();
//end first test
}
function display($content){
global $y;
return $y->callback($content);
}
}
class Y {
function callback($buffer)
{
// replace all the apples with oranges
return (str_replace("apples", "oranges", $buffer));
}
}
$x = new X;
$y = new Y;
$x->test();
//second test
?>
<html>
<body>
<p>It's like comparing apples to oranges.</p>
</body>
</html>
<?php
ob_end_flush();
//end second test
?>