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 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
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.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 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.
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.33
fork has been disabled for security reasons
Process exited with code 127.
Output for 7.1.20, 7.2.5 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.32
Notice: Undefined variable: pipes in /in/jMDAM on line 14 Warning: proc_open() has been disabled for security reasons in /in/jMDAM on line 14 Fatal error: Uncaught Exception: proc_open failed. in /in/jMDAM:15 Stack trace: #0 /in/jMDAM(39): proc_diff('foo\nbar\n', 'foo\nbar\nbaz\n', '-u') #1 {main} thrown in /in/jMDAM on line 15
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.7
array(3) { ["stdout"]=> string(0) "" ["stderr"]=> string(0) "" ["code"]=> int(127) }

preferences:
159.68 ms | 402 KiB | 172 Q