3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $url = 'http://moscow.auto.ru/cars/alfa-romeo/giulia/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, $url); $out = curl_exec($ch); // line endings is the wonkiest piece of this whole thing $out = str_replace("\r", "", $out); var_dump($out); // only look at the headers $headers_end = strpos($out, "\n\n"); if( $headers_end !== false ) { $out = substr($out, 0, $headers_end); } $headers = explode("\n", $out); foreach($headers as $header) { if( substr($header, 0, 10) == "Location: " ) { $target = substr($header, 10); echo "[$url] redirects to [$target]<br>"; continue 2; } } echo "[$url] does not redirect<br>";
Output for hhvm-3.10.0 - 3.12.0
string(0) "" [http://moscow.auto.ru/cars/alfa-romeo/giulia/] does not redirect<br>
Output for 5.3.0 - 5.4.29
Fatal error: Call to undefined function curl_init() in /in/UBko5 on line 4
Process exited with code 255.