3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getDescriptionAttribute($string) { $pattern = "~(https?://\S+)|([^\s@]+@[^\s@]+)|(\+\d+)~"; return preg_replace_callback($pattern, function($matches) { $template = '<a href="%1$s%2$s" rel="noopener nofollow" target="_blank">%2$s</a>'; if ($matches[1] !== "") return sprintf($template, "", $matches[1]); if ($matches[2] !== "") return sprintf($template, "mailto:", $matches[2]); if ($matches[3] !== "") return sprintf($template, "tel:", $matches[3]); }, $string); } $str = 'http://google.com tester@gmail.com +1818254545400'; echo getDescriptionAttribute($str);
Output for git.master_jit, git.master
Warning: Module "Zend OPcache" is already loaded in Unknown on line 0 Warning: Zend OPcache: module registration failed! in Unknown on line 0 <a href="http://google.com" rel="noopener nofollow" target="_blank">http://google.com</a> <a href="mailto:tester@gmail.com" rel="noopener nofollow" target="_blank">tester@gmail.com</a> <a href="tel:+1818254545400" rel="noopener nofollow" target="_blank">+1818254545400</a>
Output for rfc.property-hooks
<a href="http://google.com" rel="noopener nofollow" target="_blank">http://google.com</a> <a href="mailto:tester@gmail.com" rel="noopener nofollow" target="_blank">tester@gmail.com</a> <a href="tel:+1818254545400" rel="noopener nofollow" target="_blank">+1818254545400</a>

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:
100.15 ms | 407 KiB | 5 Q