3v4l.org

run code in 300+ PHP versions simultaneously
<?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); }

preferences:
35.58 ms | 402 KiB | 5 Q