3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function txt2link($text){ // force http: on www. $text = ereg_replace( "www\.", "http://www.", $text ); // eliminate duplicates after force $text = ereg_replace( "http://http://www\.", "http://www.", $text ); $text = ereg_replace( "https://http://www\.", "https://www.", $text ); // The Regular Expression filter $reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/"; // Check if there is a url in the text if(preg_match($reg_exUrl, $text, $url)) { // make the urls hyper links $text = preg_replace($reg_exUrl, '<a href="'.$url[0].'" rel="nofollow">'.$url[0].'</a>', $text); } // if no urls in the text just return the text return ($text); } $str = 'Hi bro! Look at my new website: www.example.com. I leard to build websites from http://another.example.net and from example.net.'; $newStr = txt2link($str); echo $newStr;
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Call to undefined function ereg_replace() in /in/2ZBeG:5 Stack trace: #0 /in/2ZBeG(22): txt2link('Hi bro! Look at...') #1 {main} thrown in /in/2ZBeG on line 5
Process exited with code 255.
Output for 4.3.0 - 5.2.17, hhvm-3.10.0 - 3.12.0
Hi bro! Look at my new website: <a href="http://www.example.com" rel="nofollow">http://www.example.com</a>. I leard to build websites from <a href="http://www.example.com" rel="nofollow">http://www.example.com</a> and from example.net.
Output for 5.3.0 - 5.6.28
Deprecated: Function ereg_replace() is deprecated in /in/2ZBeG on line 5 Deprecated: Function ereg_replace() is deprecated in /in/2ZBeG on line 7 Deprecated: Function ereg_replace() is deprecated in /in/2ZBeG on line 8 Hi bro! Look at my new website: <a href="http://www.example.com" rel="nofollow">http://www.example.com</a>. I leard to build websites from <a href="http://www.example.com" rel="nofollow">http://www.example.com</a> and from example.net.