3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); $cmd = 'php -r "fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); fwrite(STDERR, $in);"'; $descriptors = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w')); $stdin = str_repeat('*', 4097); $options = array_merge(array('suppress_errors' => true, 'binary_pipes' => true, 'bypass_shell' => false)); $process = proc_open($cmd, $descriptors, $pipes, getcwd(), array(), $options); foreach ($pipes as $pipe) { stream_set_blocking($pipe, false); } $writePipes = array($pipes[0]); $stdinLen = strlen($stdin); $stdinOffset = 0; unset($pipes[0]); while ($pipes || $writePipes) { $r = $pipes; $w = $writePipes; $e = null; $n = stream_select($r, $w, $e, 60); if (false === $n) { break; } elseif ($n === 0) { proc_terminate($process); } if ($w) { $written = fwrite($writePipes[0], (binary)substr($stdin, $stdinOffset), 8192); if (false !== $written) { $stdinOffset += $written; } if ($stdinOffset >= $stdinLen) { fclose($writePipes[0]); $writePipes = null; } } foreach ($r as $pipe) { $type = array_search($pipe, $pipes); $data = fread($pipe, 8192); if (false === $data || feof($pipe)) { fclose($pipe); unset($pipes[$type]); } } }
Output for 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Uncaught Error: Call to undefined function proc_open() in /in/hKfZj:10 Stack trace: #0 {main} thrown in /in/hKfZj on line 10
Process exited with code 255.
Output for 8.0.13
fork has been disabled for security reasons
Process exited with code 255.
Output for 7.3.32 - 7.3.33, 7.4.26, 7.4.33
fork has been disabled for security reasons
Process exited with code 127.
Output for 7.4.0 - 7.4.25, 7.4.27 - 7.4.32
Notice: Undefined variable: pipes in /in/hKfZj on line 10 Warning: proc_open() has been disabled for security reasons in /in/hKfZj on line 10 Notice: Undefined variable: pipes in /in/hKfZj on line 12 Warning: Invalid argument supplied for foreach() in /in/hKfZj on line 12 Notice: Undefined variable: pipes in /in/hKfZj on line 15 Notice: Trying to access array offset on value of type null in /in/hKfZj on line 15 Notice: Undefined variable: pipes in /in/hKfZj on line 19 Notice: Undefined variable: pipes in /in/hKfZj on line 21 Notice: Undefined variable: pipes in /in/hKfZj on line 22 Warning: stream_select(): supplied argument is not a valid stream resource in /in/hKfZj on line 25 Warning: stream_select(): No stream arrays were passed in /in/hKfZj on line 25
Output for 7.2.29 - 7.2.33, 7.3.12 - 7.3.31
Notice: Undefined variable: pipes in /in/hKfZj on line 10 Warning: proc_open() has been disabled for security reasons in /in/hKfZj on line 10 Notice: Undefined variable: pipes in /in/hKfZj on line 12 Warning: Invalid argument supplied for foreach() in /in/hKfZj on line 12 Notice: Undefined variable: pipes in /in/hKfZj on line 15 Notice: Undefined variable: pipes in /in/hKfZj on line 19 Notice: Undefined variable: pipes in /in/hKfZj on line 21 Notice: Undefined variable: pipes in /in/hKfZj on line 22 Warning: stream_select(): supplied argument is not a valid stream resource in /in/hKfZj on line 25 Warning: stream_select(): No stream arrays were passed in /in/hKfZj on line 25
Output for 7.0.12, 7.0.20, 7.1.0, 7.1.6 - 7.1.10, 7.2.0

Process exited with code 137.
Output for 5.2.1 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.21, 7.0.0 - 7.0.6, 7.0.14, 7.1.5
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0
Parse error: syntax error, unexpected T_STRING in /in/hKfZj on line 34
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STRING in /in/hKfZj on line 34
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/hKfZj on line 34
Process exited with code 255.

preferences:
218.93 ms | 401 KiB | 309 Q