3v4l.org

run code in 300+ PHP versions simultaneously
<?php const URL_ROOT = 'http://www.jd.com'; $host = parse_url(URL_ROOT, PHP_URL_HOST) or die('Invalid URL_ROOT'); $url = URL_ROOT . $_SERVER['REQUEST_URI']; // Request URL $ch = curl_init($url) or die('curl_init failed.'); // Request Method curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $_SERVER['REQUEST_METHOD']); // Request Headers $headers = getallheaders(); $headers['Host'] = $host; $ch_headers = array(); foreach ($headers as $name => $value) $ch_headers[] = "$name: $value"; curl_setopt($ch, CURLOPT_HTTPHEADER, $ch_headers); // Request Body curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents("php://input")); // Send curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch) or die('curl_exec failed.'); $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); curl_close($ch); // Response Header $header = substr($response, 0, $header_size); $headers = explode("\r\n", $header); foreach ($headers as $header) header($header); // Response Body $body = substr($response, $header_size); echo $body;
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined array key "REQUEST_URI" in /in/ZS3FN on line 5 Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/ZS3FN:8 Stack trace: #0 {main} thrown in /in/ZS3FN on line 8
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
37.95 ms | 401 KiB | 8 Q