3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function file_get_contents_curl($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $data = curl_exec($ch); curl_close($ch); return $data; } $html = file_get_contents_curl("https://translate.google.it"); //parsing begins here: $doc = new DOMDocument(); @$doc->loadHTML($html); $nodes = $doc->getElementsByTagName('title'); //get and display what you need: $title = $nodes->item(0)->nodeValue; $metas = $doc->getElementsByTagName('meta'); for ($i = 0; $i < $metas->length; $i++) { $meta = $metas->item($i); if($meta->getAttribute('name') == 'description') $description = $meta->getAttribute('content'); if($meta->getAttribute('name') == 'keywords') $keywords = $meta->getAttribute('content'); } echo "Title: $title". '<br/><br/>'; echo "Description: $description". '<br/><br/>'; echo "Keywords: $keywords";
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/tscBC:5 Stack trace: #0 /in/tscBC(18): file_get_contents_curl('https://transla...') #1 {main} thrown in /in/tscBC on line 5
Process exited with code 255.
Output for 5.3.18 - 5.6.28
Fatal error: Call to undefined function curl_init() in /in/tscBC on line 5
Process exited with code 255.