3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function txt2link($text){ // force http: on www. $text = preg_replace( "www\.", "http://www.", $text ); // eliminate duplicates after force $text = preg_replace( "http://http://www\.", "http://www.", $text ); $text = preg_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); } echo txt2link('http://www.snoodo.com');
Output for 4.3.11 - 5.6.28, 7.0.0 - 7.1.0
Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in /in/3l3gB on line 4 Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in /in/3l3gB on line 6 Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in /in/3l3gB on line 7
Output for hhvm-3.12.0
Warning: Delimiter must not be alphanumeric or backslash in /in/3l3gB on line 4 Warning: Delimiter must not be alphanumeric or backslash in /in/3l3gB on line 6 Warning: Delimiter must not be alphanumeric or backslash in /in/3l3gB on line 7 Warning: preg_match() expects parameter 2 to be string, null given in /in/3l3gB on line 12
Output for 4.3.0 - 4.3.10, hhvm-3.10.0
Warning: Delimiter must not be alphanumeric or backslash in /in/3l3gB on line 4 Warning: Delimiter must not be alphanumeric or backslash in /in/3l3gB on line 6 Warning: Delimiter must not be alphanumeric or backslash in /in/3l3gB on line 7