3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $descriptorspec = array( 0 => array("pipe", "r"), // stdin is a pipe that the child will read from 1 => array("pipe", "w"), // stdout is a pipe that the child will write to 2 => array("file", "error-output.txt", "a") // stderr is a file to write to ); $cwd = '/tmp'; $env = array('some_option' => 'aeiou'); $process = proc_open('php', $descriptorspec, $pipes, $cwd, $env); if (is_resource($process)) { // $pipes now looks like this: // 0 => writeable handle connected to child stdin // 1 => readable handle connected to child stdout // Any error output will be appended to /tmp/error-output.txt fwrite($pipes[0], '<?php print_r($_ENV); ?>'); fclose($pipes[0]); echo stream_get_contents($pipes[1]); fclose($pipes[1]); // It is important that you close any pipes before calling // proc_close in order to avoid a deadlock $return_value = proc_close($process); echo "command returned $return_value\n"; } ?>
Output for 5.2.3 - 5.6.28, 7.0.0 - 7.1.0
Warning: proc_open(error-output.txt): failed to open stream: Permission denied in /in/KidJf on line 11
Output for hhvm-3.10.0 - 3.12.0
Warning: Permission denied in /in/KidJf on line 11 Warning: Unable to open specified file: error-output.txt (mode a) in /in/KidJf on line 11
Output for 5.0.0 - 5.2.2
Warning: proc_open(error-output.txt): failed to open stream: Read-only file system in /in/KidJf on line 11
Output for 4.3.0 - 4.4.9
Warning: proc_open() expects exactly 3 parameters, 5 given in /in/KidJf on line 11