3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $url = 'https://secure.i-web.ch/dweb/uri/de/behoerdenmain/gerichtetop/rechtsprechung/?action=info&pubid=4762'; $site = getSiteContent($url); // echo $site; $linksArr = getDomLinks($site); displayArray($linksArr); exit; function getSiteContent($url, $cookieFile = NULL) { $ch = curl_init(); $timeout = 5; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0'); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile); $data = curl_exec($ch); curl_close($ch); return $data; } function getDomLinks($contents) { $linkArr = array(); $dom = new domDocument; @$dom->loadHTML($contents); $links = $dom->getElementsByTagName('a'); foreach ($links as $tag) { $linkArr[$tag->getAttribute('href')] = $tag->childNodes->item(0)->nodeValue; } return $linkArr; } function displayArray($aArray) { if (is_array($aArray) && (count($aArray) > 0)) { print("<table border=1>"); print("<tr><th>Key</th><th>Value</th></tr>"); foreach ($aArray as $aKey => $aValue) { print("<tr>"); if (!is_array($aValue)) { if (empty($aValue)) { print("<td>$aKey</td><td><i>$aValue</i></td>"); } else { print("<td>$aKey</td><td>$aValue</td>"); } } else { print("<td>$aKey(array)</td><td>"); displayArray($aValue); print("</td>"); } print("</tr>"); } print("</table>"); } else { print("<i>empty or invalid</i>"); } } ?>
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/slLXK:15 Stack trace: #0 /in/slLXK(5): getSiteContent('https://secure....') #1 {main} thrown in /in/slLXK on line 15
Process exited with code 255.
Output for hhvm-3.12.0
<i>empty or invalid</i>
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.0.0 - 5.6.28
Fatal error: Call to undefined function curl_init() in /in/slLXK on line 15
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/slLXK on line 38
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/slLXK on line 38
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/slLXK on line 38
Process exited with code 255.