3v4l.org

run code in 500+ PHP versions simultaneously
<?php $default = 'hacs.xyz'; $url = ltrim($_GET['u'] ?? $_SERVER['QUERY_STRING'] ?? $_SERVER['REQUEST_URI'] ?? '', '/') ?: $default; $url = preg_replace('#^index\.php/#i', '', $url); if (in_array($url, ['', 'favicon.ico', 'opensearch.xml'])) { exit(); } if (!preg_match('/https?:/i', $url)) { $url = "https://$url"; } list($body, $headers) = request($url); foreach ($headers as $k => $v) { if (in_array(strtolower($k), ['content-type', 'content-encoding'])) { header("$k: $v"); } } echo $body; function request($url) { error_log($url); $ua = $_SERVER['HTTP_USER_AGENT'] ?? 'Mozilla/5.0 Chrome/139'; $headers = ["Content-Type: $ua\r\n"]; if ($ref = $_SERVER['HTTP_REFERER'] ?? '') { $headers[] = "Referer: $ref\r\n"; } $http = [ 'method' => 'GET', 'header' => join($headers), ]; $context = stream_context_create(compact('http')); $body = file_get_contents($url, false, $context); $headers = array_reduce($http_response_header ?? [], function ($dat, $head) { $arr = explode(':', $head, 2); if (isset($arr[1])) { $dat[$arr[0]] = trim($arr[1]); } return $dat; }, []); if ($location = $headers['Location'] ?? $headers['location'] ?? null) { if (str_starts_with($location, '/')) { $schema = parse_url($url, PHP_URL_SCHEME); $host = parse_url($url, PHP_URL_HOST); $location = "$schema://$host$location"; } return request($location); } return [$body, $headers]; }
Output for 8.5.1 - 8.5.3
Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/aoBfV on line 34 Warning: file_get_contents(https://hacs.xyz): Failed to open stream: No such file or directory in /in/aoBfV on line 34 https://hacs.xyz
Output for 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0
Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/aoBfV on line 34 Warning: file_get_contents(): open_basedir restriction in effect. File(https://hacs.xyz) is not within the allowed path(s): (/tmp:/in:/etc) in /in/aoBfV on line 34 Warning: file_get_contents(https://hacs.xyz): Failed to open stream: Operation not permitted in /in/aoBfV on line 34 https://hacs.xyz

preferences:
53.67 ms | 874 KiB | 4 Q