0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-11-10 06:08:40 +00:00
phpv8/samples/debug_line_processor.php

23 lines
406 B
PHP
Raw Normal View History

2013-10-12 18:44:15 +00:00
<?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).');');
}