3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php public 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 'public' (T_PUBLIC) in /in/rAhQL on line 3
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_PUBLIC in /in/rAhQL on line 3
Process exited with code 255.