3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function fwrite_with_retry($sock, &$data) { $bytes_to_write = strlen($data); $bytes_written = 0; while ( $bytes_written < $bytes_to_write ) { if ( $bytes_written == 0 ) { $rv = fwrite($sock, $data); } else { $rv = fwrite($sock, substr($data, $bytes_written)); } if ( $rv === false || $rv == 0 ) return( $bytes_written == 0 ? false : $bytes_written ); $bytes_written += $rv; } return $bytes_written; } $fp = fsockopen("localhost", 80, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { $out = "GET / HTTP/1.1\r\n"; $out .= "Host: 3v4l.org\r\n"; $out .= "Connection: Close\r\n\r\n"; fwrite_with_retry($fp, $out); while (!feof($fp)) { echo fgets($fp, 128); } fclose($fp); }
based on 1Yhvc
Output for 5.4.39 - 5.6.28, 7.0.0 - 7.1.0
Warning: fsockopen(): unable to connect to localhost:80 (Connection refused) in /in/DDW4L on line 24 Connection refused (111)<br />
Output for hhvm-3.10.0 - 3.12.0
Warning: failed to connect to localhost [111]: Connection refused in /in/DDW4L on line 24 Connection refused (111)<br />
Output for 5.0.0 - 5.4.38
Warning: fsockopen(): unable to connect to localhost:80 (Network is unreachable) in /in/DDW4L on line 24 Network is unreachable (101)<br />
Output for 4.3.3 - 4.4.9
Warning: fsockopen(): unable to connect to localhost:80 in /in/DDW4L on line 24 Network is unreachable (101)<br />
Output for 4.3.2
Warning: fsockopen(): php_hostconnect: connect failed in /in/DDW4L on line 24 Warning: fsockopen(): unable to connect to localhost:80 in /in/DDW4L on line 24 Network is unreachable (101)<br />
Output for 4.3.0 - 4.3.1

Process exited with code 139.