3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<< HTML <html> <base> <base href="http://example.com"/> </head> <body> <a href="//foo">foo</a> <a href="bar">bar</a> <a href="http://somewhere.else">somewhere else</a> <a href="tel://911">halp!</a> <a href="mailto:spam.pls@example.com">spam me</a> <a href="javascript:alert('hi')">say hi</a> </body> </html> HTML; $dom = new DOMDocument; $dom->loadHTML($html); $xpath = new DOMXPath($dom); $base = $xpath->evaluate('string(/html/head/base/@href)'); foreach ($xpath->evaluate('//a/@href') as $link) { if (strpos($link->nodeValue, 'http') === 0) { echo $link->nodeValue, PHP_EOL; } elseif (strpos($link->nodeValue, '//') === 0) { echo $base, substr($link->nodeValue, 1), PHP_EOL; } elseif (strpos($link->nodeValue, ':') === FALSE) { echo $base, '/', $link->nodeValue, PHP_EOL; } }
Output for git.master, git.master_jit, rfc.property-hooks
http://example.com/foo http://example.com/bar http://somewhere.else

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:
50.49 ms | 1597 KiB | 4 Q