Created
November 19, 2012 15:47
-
-
Save clone1018/4111382 to your computer and use it in GitHub Desktop.
Code
This file contains hidden or 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 | |
echo "output starts here".PHP_EOL; | |
$php = new Runkit_Sandbox(); | |
$php['output_handler'] = 'test_handler'; | |
$php->echo("foo\n"); | |
$php->echo("Barish\n"); | |
$php->echo("BAZimbly\n"); | |
var_dump($php['output_handler']); | |
function test_handler($str) { | |
if (strlen($str) == 0) return NULL; /* Do nothing with flush events */ | |
/* Echoing and returning have the same effect here, both go to parent's output chain */ | |
echo 'Received string from sandbox: ' . strlen($str) . " bytes long.\n"; | |
return strtoupper($str); | |
} | |
echo "end output".PHP_EOL; |
This file contains hidden or 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
output starts here | |
string(12) "test_handler" | |
end output | |
Received string from sandbox: 20 bytes long. | |
FOO | |
BARISH | |
BAZIMBLY |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment