3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dom = new DOMDocument(); $dom->loadHtml(' Hello World have a look at <a href="www.laptops.com/apple">Apple Laptops</a>. For more ino go to <a href="www.apple.com">Apple.com</a> or to <a href="www.appleblog.com">Appleblog.com</a> ', LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($dom); foreach ($xpath->query("//a") as $link) { $href = $link->getAttribute('href'); // link has a # in it, so replace with the links title if (strpos($href, 'www.laptops.com') === false) { $link->setAttribute("rel", "nofollow noopener"); } } echo $dom->saveHTML();
Output for git.master_jit, git.master, rfc.property-hooks
<p>Hello World have a look at <a href="www.laptops.com/apple">Apple Laptops</a>. For more ino go to <a href="www.apple.com" rel="nofollow noopener">Apple.com</a> or to <a href="www.appleblog.com" rel="nofollow noopener">Appleblog.com</a> </p>

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:
18.03 ms | 402 KiB | 8 Q