3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); /* * PHP 8.0+ throw exception in error handler while proc_open executable not in path warning exit code 127 (shell/system) */ error_reporting(~0); function error_handler($code, $message, $file, $line) { fprintf(STDOUT, "error: %s ** and throw **\n", var_export(array_slice(func_get_args(), 0, 4), true)); throw new ErrorException($message, 0, $code, $file, $line); // non-catchable non-fatal exception } set_error_handler('error_handler', ~0); $pipes = []; // command must be passed as array to trigger this, string won't work. $process = proc_open(['non-existent-command'], [], $pipes); // directly produce some output fprintf(STDOUT, "open: %d\n", $process); $status = proc_get_status($process); ksort($status); fprintf(STDOUT, "status: %s\n", json_encode($status)); // let proc finish usleep(100000); $status = proc_get_status($process); ksort($status); fprintf(STDOUT, "status: %s\n", json_encode($status)); $close = proc_close($process); fprintf(STDOUT, "close: %s\n", var_export($close, true));
Output for 8.5.1 - 8.5.3
error: array ( 0 => 2, 1 => 'proc_open(): posix_spawn() failed: No such file or directory', 2 => '/in/gXjcI', 3 => 17, ) ** and throw ** Fatal error: Uncaught ErrorException: proc_open(): posix_spawn() failed: No such file or directory in /in/gXjcI:17 Stack trace: #0 [internal function]: error_handler(2, 'proc_open(): po...', '/in/gXjcI', 17) #1 /in/gXjcI(17): proc_open(Array, Array, Array) #2 {main} thrown in /in/gXjcI on line 17
Process exited with code 255.
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0
Fatal error: Uncaught Error: Call to undefined function proc_open() in /in/gXjcI:17 Stack trace: #0 {main} thrown in /in/gXjcI on line 17
Process exited with code 255.

preferences:
85.56 ms | 1122 KiB | 4 Q