3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function formatUrlsInText($text){ $reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/"; preg_match_all($reg_exUrl, $text, $matches); $usedPatterns = array(); foreach($matches[0] as $pattern){ if(!array_key_exists($pattern, $usedPatterns)){ $usedPatterns[$pattern]=true; $text = str_replace($pattern, "<a href=".$pattern." rel="nofollow">{$pattern}</a> ", $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 = formatUrlsInText($str); echo $newStr;
Output for 5.4.0 - 5.4.27
Parse error: syntax error, unexpected 'nofollow' (T_STRING) in /in/1Z4ig on line 10
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_STRING in /in/1Z4ig on line 10
Process exited with code 255.