0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-09-19 23:35:19 +00:00
phpv8/samples/debug_line_processor.php
2013-10-13 11:36:57 +02:00

23 lines
406 B
PHP

<?php
$v8 = new V8Js();
$v8->startDebugAgent('LineProcessor', 9222, V8Js::DEBUG_AUTO_BREAK_ALWAYS);
$JS = <<< EOT
print("Hello LineProcessor User!\\n");
function processLine(foo) {
return foo.toUpperCase();
};
EOT;
$v8->executeString($JS, 'processor.js');
$fh = fopen('php://stdin', 'r');
while(($line = fgets($fh))) {
echo $v8->executeString('processLine('.json_encode($line).');');
}