3v4l.org

run code in 300+ PHP versions simultaneously
<?php $descSpec = array( array('pipe','r'), // stdin array('pipe','w'), // stdout array('pipe','w') // stderr ); $proc = proc_open('bash', $descSpec, $pipes,'/tmp',array()); if(!is_resource($proc)){ throw new Exception("Could not open bash process"); } $stdin = &$pipes[0]; $stdout = &$pipes[1]; $stderr = &$pipes[2]; stream_set_blocking($stdout,0); stream_set_blocking($stderr,0); fwrite($stdin, "pwd\n"); fflush($stdin); $write = null; $except = null; $stdoutArr = array($stdout); $rv = stream_select($stdoutArr,$write,$except,1); $strIn = stream_get_line($stdout,4096); var_export(array('streamSelect_returnVal'=>$rv,'stdout_strRead'=>$strIn));

preferences:
41.74 ms | 402 KiB | 5 Q