3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php header('Content-Type: text/plain; charset=utf-8'); $body = file_get_contents('http://chat.stackoverflow.com/search?q=tag%3Acv-pls%20tag%3Adelv-pls&Room=11&page=1&pagesize=50&sort=newest'); $qids = []; libxml_use_internal_errors(true); $doc = new DOMDocument; $doc->loadHTML($body); $xpath = new DOMXpath($doc); $nodes = $xpath->query("//a[contains(@href, 'tagged')]/following-sibling::a[not(contains(@href, 'tagged')) and not(contains(@href, '#'))]"); foreach ($nodes as $node) { /** @var $node DOMElement */ if (preg_match('#(?:q|questions)/(?P<qid>\d+)#', $node->getAttribute('href'), $matches)) { $qids[] = $matches['qid']; } } print_r($qids);
Output for 5.4.0 - 7.1.0
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/GBcMZ on line 5 Warning: file_get_contents(http://chat.stackoverflow.com/search?q=tag%3Acv-pls%20tag%3Adelv-pls&Room=11&page=1&pagesize=50&sort=newest): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/GBcMZ on line 5 Warning: DOMDocument::loadHTML(): Empty string supplied as input in /in/GBcMZ on line 10 Array ( )
Output for 5.2.3 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/GBcMZ on line 6
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.2
<br /> <b>Parse error</b>: syntax error, unexpected '[' in <b>/in/GBcMZ</b> on line <b>6</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
<br /> <b>Parse error</b>: parse error, unexpected '[' in <b>/in/GBcMZ</b> on line <b>6</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Parse error</b>: parse error in <b>/in/GBcMZ</b> on line <b>6</b><br />
Process exited with code 255.