3v4l.org

run code in 300+ PHP versions simultaneously
<?php //a URL you want to retrieve $my_url = 'http://www.digg.com'; $html = file_get_contents($my_url); $dom = new DOMDocument(); $dom->loadHTML($html); $xpath = new DOMXPath($dom); //Put your XPath Query here $my_xpath_query = "/html/body/div[@id='container']/div[@id='contents']/div[@class='list' and @id='wrapper']/div[@class='main' and position()=1]/div[contains(@class, 'news-summary')]/div[@class='news-body']/h3"; $result_rows = $xpath->query($my_xpath_query); //here we loop through our results (a DOMDocument Object) foreach ($result_rows as $result_object){ echo $result_object->childNodes->item(0)->nodeValue; } ?>
Output for git.master, git.master_jit, rfc.property-hooks
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo for www.digg.com failed: System error in /in/KjE59 on line 5 Warning: file_get_contents(http://www.digg.com): Failed to open stream: php_network_getaddresses: getaddrinfo for www.digg.com failed: System error in /in/KjE59 on line 5 Fatal error: Uncaught ValueError: DOMDocument::loadHTML(): Argument #1 ($source) must not be empty in /in/KjE59:7 Stack trace: #0 /in/KjE59(7): DOMDocument->loadHTML('') #1 {main} thrown in /in/KjE59 on line 7
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:
56.16 ms | 401 KiB | 8 Q