-
-
Save mjrider/09d326f287f318956a04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class oob { | |
private $buffer = ''; | |
private $oob = ''; | |
function __construct() { | |
ob_start([$this, 'obhandler']); | |
} | |
function __destruct() { | |
ob_end_flush(); | |
echo $this->buffer; | |
} | |
function oob($buffer) { | |
$this->oob .= $buffer; | |
ob_flush(); | |
} | |
function obhandler($buffer){ | |
$this->buffer .= $buffer; | |
$oob = $this->oob; | |
$this->oob = ''; | |
return $oob; | |
} | |
} | |
$oob = new oob(); | |
for($i=0 ; $i<10 ; $i++) { | |
print "frop".$i."\n"; | |
$oob->oob('frml'.$i."\n"); | |
} | |
unset($oob); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
de output is:
frml0
frml1
frml2
frml3
frml4
frml5
frml6
frml7
frml8
frml9
frop0
frop1
frop2
frop3
frop4
frop5
frop6
frop7
frop8
frop9