3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getbody($url) { $dom = new DOMDocument; //$dom->loadHTML($file); $dom->loadHTMLFile($url); $bodies = $dom->getElementsByTagName('body'); assert($bodies->length === 1); $body = $bodies->item(0); for ($i = 0; $i < $body->children->length; $i++) { $body->remove($body->children->item($i)); } $stringbody = $dom->saveHTML($body); return $stringbody; } //$url = "http://stackoverflow.com"; $url = "http://www.barcelona.com"; $body = getbody($url); //var_dump($body); ?> <html> <head></head> <body> <?php echo "BODY ripped from: ".$url."<br/>"; echo "<textarea rows='40' cols='200' >".$body."</textarea>"; ?> </body> </html>
Output for git.master, git.master_jit, rfc.property-hooks
Warning: DOMDocument::loadHTMLFile(): php_network_getaddresses: getaddrinfo for www.barcelona.com failed: System error in /in/Ucrc9 on line 5 Warning: DOMDocument::loadHTMLFile(http://www.barcelona.com): Failed to open stream: php_network_getaddresses: getaddrinfo for www.barcelona.com failed: System error in /in/Ucrc9 on line 5 Warning: DOMDocument::loadHTMLFile(): I/O warning : failed to load external entity "http://www.barcelona.com" in /in/Ucrc9 on line 5 Fatal error: Uncaught AssertionError: assert($bodies->length === 1) in /in/Ucrc9:7 Stack trace: #0 /in/Ucrc9(7): assert(false, 'assert($bodies-...') #1 /in/Ucrc9(17): getbody('http://www.barc...') #2 {main} thrown in /in/Ucrc9 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:
46.32 ms | 402 KiB | 8 Q