3v4l.org

run code in 300+ PHP versions simultaneously
<?php function proc_diff($text1, $text2, $options='') { $descriptors = [ 0 => [ 'file', '/dev/null', 'r' ], 1 => [ 'pipe', 'w' ], 2 => [ 'pipe', 'w' ], 3 => [ 'pipe', 'r' ], 4 => [ 'pipe', 'r' ], ]; $command = sprintf('diff %s /proc/self/fd/3 /proc/self/fd/4', $options); if( ! $p = proc_open( $command, $descriptors, $pipes ) ) { throw new \Exception('proc_open failed.'); } fwrite($pipes[3], $text1); fwrite($pipes[4], $text2); fclose($pipes[3]); fclose($pipes[4]); $ret = []; $ret['stdout'] = stream_get_contents($pipes[1]); $ret['stderr'] = stream_get_contents($pipes[2]); fclose($pipes[1]); fclose($pipes[2]); $ret['code'] = proc_close($p); return $ret; } $in1 = "foo\nbar\n"; $in2 = "foo\nbar\nbaz\n"; var_dump(proc_diff($in1, $in2, '-u'));
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined function proc_open() in /in/jMDAM:14 Stack trace: #0 /in/jMDAM(39): proc_diff('foo\nbar\n', 'foo\nbar\nbaz\n', '-u') #1 {main} thrown in /in/jMDAM on line 14
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
30.55 ms | 401 KiB | 8 Q