3v4l.org

run code in 300+ PHP versions simultaneously
<?php $i=1; while ($i<=5) { # code... $url = 'http://www.amazon.in/gp/bestsellers/electronics/ref=zg_bs_nav_0#'.$i; echo $url; $html= file_get_contents($url); $dom = new DOMDocument(); @$dom->loadHTML($html); $xPath = new DOMXPath($dom); $classname="zg_title"; $elements = $xPath->query("//*[contains(@class, '$classname')]"); foreach ($elements as $e) { $lnk = $e->getAttribute('href'); $e->setAttribute("href", "http://www.amazon.in".$lnk); $newdoc = new DOMDocument; $e = $newdoc->importNode($e, true); $newdoc->appendChild($e); $html = $newdoc->saveHTML(); echo $html; } $i++; } ?>
Output for git.master, git.master_jit, rfc.property-hooks
http://www.amazon.in/gp/bestsellers/electronics/ref=zg_bs_nav_0#1 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo for www.amazon.in failed: System error in /in/JH6Gk on line 9 Warning: file_get_contents(http://www.amazon.in/gp/bestsellers/electronics/ref=zg_bs_nav_0#1): Failed to open stream: php_network_getaddresses: getaddrinfo for www.amazon.in failed: System error in /in/JH6Gk on line 9 Fatal error: Uncaught ValueError: DOMDocument::loadHTML(): Argument #1 ($source) must not be empty in /in/JH6Gk:11 Stack trace: #0 /in/JH6Gk(11): DOMDocument->loadHTML('') #1 {main} thrown in /in/JH6Gk on line 11
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:
57.15 ms | 402 KiB | 8 Q