pub fn run_program(src: &str, input: &str) -> Result<String, String>Expand description
Run src as a complete program with input as its stdin and return
everything it wrote to stdout.
Each call runs on its own thread with a fresh host (the host and every other
piece of interpreter state are thread-local), so nothing leaks between calls
and concurrent calls never share an output buffer. src is a PHP file’s
text, so it starts in HTML mode: PHP code needs its <?php tag.
inputis whatSTDIN,php://stdinandreadline()read.- Output is captured below the output-buffering stack;
fwrite(STDOUT, …)lands there too. Diagnostics are displayed into the output as the CLI displays them on stdout; their log copies still go to the process stderr. - The request shutdown runs as under the CLI: shutdown functions, destructors, then the open output buffers.
Errfor a parse or compile error, an uncaught exception or fatal error (its message), a nonzeroexit/diestatus (exit status N), or a panic in the runtime.exit(0),exit("text")anddiewith no status areOkwith the output up to that point.