Skip to content

Instantly share code, notes, and snippets.

@clone1018
Created November 19, 2012 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clone1018/4111382 to your computer and use it in GitHub Desktop.
Save clone1018/4111382 to your computer and use it in GitHub Desktop.
Code
<?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;
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