3v4l.org

run code in 300+ PHP versions simultaneously
<?php $mirror = "the.site-you-want-to-mirror.com"; // Change this value to the site you want to mirror. $req = $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . " HTTP/1.0\r\n"; $length = 0; foreach ($_SERVER as $k => $v) { if (substr($k, 0, 5) == "HTTP_") { $k = str_replace('_', ' ', substr($k, 5)); $k = str_replace(' ', '-', ucwords(strtolower($k))); if ($k == "Host") $v = $mirror; # Alter "Host" header to mirrored server if ($k == "Accept-Encoding") $v = "identity;q=1.0, *;q=0"; # Alter "Accept-Encoding" header to accept unencoded content only if ($k == "Keep-Alive") continue; # Drop "Keep-Alive" header if ($k == "Connection" && $v == "keep-alive") $v = "close"; # Alter value of "Connection" header from "keep-alive" to "close" $req .= $k . ": " . $v . "\r\n"; } } $body = @file_get_contents('php://input'); $req .= "Content-Type: " . $_SERVER['CONTENT_TYPE'] . "\r\n"; $req .= "Content-Length: " . strlen($body) . "\r\n"; $req .= "\r\n"; $req .= $body; #print $req; $fp = fsockopen($mirror, 80, $errno, $errmsg, 30); if (!$fp) { print "HTTP/1.0 502 Failed to connect remote server\r\n"; print "Content-Type: text/html\r\n\r\n"; print "<html><body>Failed to connect to $mirror due to:<br>[$errno] $errstr</body></html>"; exit; } fwrite($fp, $req); $headers_processed = 0; $reponse = ''; while (!feof($fp)) { $r = fread($fp, 8192); if (!$headers_processed) { $response .= $r; $nlnl = strpos($response, "\r\n\r\n"); $add = 4; if (!$nlnl) { $nlnl = strpos($response, "\n\n"); $add = 2; } if (!$nlnl) continue; $headers = substr($response, 0, $nlnl); $cookies = 'Set-Cookie: '; if (preg_match_all('/^(.*?)(\r?\n|$)/ims', $headers, $matches)) for ($i = 0; $i < count($matches[0]); ++$i) { $ct = $matches[1][$i]; # if (substr($ct, 0, 12) == "Set-Cookie: ") { # $cookies .= substr($ct, 12) . ','; # header($cookies); # } else header($ct, false); # print '>>' . $ct . "\r\n"; } print substr($response, $nlnl + $add); $headers_processed = 1; } else print $r; } fclose ($fp); ?>
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: Undefined array key "REQUEST_METHOD" in /in/jYOo3 on line 5 Warning: Undefined array key "REQUEST_URI" in /in/jYOo3 on line 5 Warning: Undefined array key "CONTENT_TYPE" in /in/jYOo3 on line 23 Warning: fsockopen(): php_network_getaddresses: getaddrinfo for the.site-you-want-to-mirror.com failed: System error in /in/jYOo3 on line 30 Warning: fsockopen(): Unable to connect to the.site-you-want-to-mirror.com:80 (php_network_getaddresses: getaddrinfo for the.site-you-want-to-mirror.com failed: System error) in /in/jYOo3 on line 30 HTTP/1.0 502 Failed to connect remote server Content-Type: text/html Warning: Undefined variable $errstr in /in/jYOo3 on line 34 <html><body>Failed to connect to the.site-you-want-to-mirror.com due to:<br>[0] </body></html>
Output for 8.0.13 - 8.0.30
Warning: Undefined array key "REQUEST_METHOD" in /in/jYOo3 on line 5 Warning: Undefined array key "REQUEST_URI" in /in/jYOo3 on line 5 Warning: Undefined array key "CONTENT_TYPE" in /in/jYOo3 on line 23 Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: System error in /in/jYOo3 on line 30 Warning: fsockopen(): Unable to connect to the.site-you-want-to-mirror.com:80 (php_network_getaddresses: getaddrinfo failed: System error) in /in/jYOo3 on line 30 HTTP/1.0 502 Failed to connect remote server Content-Type: text/html Warning: Undefined variable $errstr in /in/jYOo3 on line 34 <html><body>Failed to connect to the.site-you-want-to-mirror.com due to:<br>[0] </body></html>
Output for 8.0.0 - 8.0.12
Warning: Undefined array key "REQUEST_METHOD" in /in/jYOo3 on line 5 Warning: Undefined array key "REQUEST_URI" in /in/jYOo3 on line 5 Warning: Undefined array key "CONTENT_TYPE" in /in/jYOo3 on line 23 Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /in/jYOo3 on line 30 Warning: fsockopen(): Unable to connect to the.site-you-want-to-mirror.com:80 (php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution) in /in/jYOo3 on line 30 HTTP/1.0 502 Failed to connect remote server Content-Type: text/html Warning: Undefined variable $errstr in /in/jYOo3 on line 34 <html><body>Failed to connect to the.site-you-want-to-mirror.com due to:<br>[0] </body></html>
Output for 5.5.33, 5.6.18 - 5.6.19, 7.0.4, 7.0.20, 7.1.5 - 7.1.33, 7.2.0 - 7.2.25, 7.3.0 - 7.3.12, 7.4.0, 7.4.26 - 7.4.33
Notice: Undefined index: REQUEST_METHOD in /in/jYOo3 on line 5 Notice: Undefined index: REQUEST_URI in /in/jYOo3 on line 5 Notice: Undefined index: CONTENT_TYPE in /in/jYOo3 on line 23 Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: System error in /in/jYOo3 on line 30 Warning: fsockopen(): unable to connect to the.site-you-want-to-mirror.com:80 (php_network_getaddresses: getaddrinfo failed: System error) in /in/jYOo3 on line 30 HTTP/1.0 502 Failed to connect remote server Content-Type: text/html Notice: Undefined variable: errstr in /in/jYOo3 on line 34 <html><body>Failed to connect to the.site-you-want-to-mirror.com due to:<br>[0] </body></html>
Output for 7.2.29 - 7.2.33, 7.3.16 - 7.3.31, 7.4.3 - 7.4.25
Notice: Undefined index: REQUEST_METHOD in /in/jYOo3 on line 5 Notice: Undefined index: REQUEST_URI in /in/jYOo3 on line 5 Notice: Undefined index: CONTENT_TYPE in /in/jYOo3 on line 23 Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /in/jYOo3 on line 30 Warning: fsockopen(): unable to connect to the.site-you-want-to-mirror.com:80 (php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution) in /in/jYOo3 on line 30 HTTP/1.0 502 Failed to connect remote server Content-Type: text/html Notice: Undefined variable: errstr in /in/jYOo3 on line 34 <html><body>Failed to connect to the.site-you-want-to-mirror.com due to:<br>[0] </body></html>
Output for 7.3.32 - 7.3.33
Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: System error in /in/jYOo3 on line 30 Warning: fsockopen(): unable to connect to the.site-you-want-to-mirror.com:80 (php_network_getaddresses: getaddrinfo failed: System error) in /in/jYOo3 on line 30 HTTP/1.0 502 Failed to connect remote server Content-Type: text/html <html><body>Failed to connect to the.site-you-want-to-mirror.com due to:<br>[0] </body></html>
Output for 5.5.24 - 5.5.32, 5.5.34 - 5.5.35, 5.6.8 - 5.6.17, 5.6.20 - 5.6.28, 7.0.0 - 7.0.3, 7.0.5 - 7.0.6, 7.1.0
Notice: Undefined index: REQUEST_METHOD in /in/jYOo3 on line 5 Notice: Undefined index: REQUEST_URI in /in/jYOo3 on line 5 Notice: Undefined index: CONTENT_TYPE in /in/jYOo3 on line 23 Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/jYOo3 on line 30 Warning: fsockopen(): unable to connect to the.site-you-want-to-mirror.com:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /in/jYOo3 on line 30 HTTP/1.0 502 Failed to connect remote server Content-Type: text/html Notice: Undefined variable: errstr in /in/jYOo3 on line 34 <html><body>Failed to connect to the.site-you-want-to-mirror.com due to:<br>[0] </body></html>

preferences:
177.75 ms | 404 KiB | 226 Q