Home >Backend Development >PHP Tutorial >A modified function that automatically converts URLs and emails, powerful_PHP tutorial
It can convert
starting with http and ftp, as well as mail
and
starting with www, which is very good
function enable_urls($str){
$str = ereg_replace("(www.[a-zA-Z0-9@:%_.~#-?&]+)", " 1", $str);// Automatically convert links starting with www
$ str = ereg_replace("(((f|ht){1}tp://)[a-zA-Z0-9@:%_.~#-?&]+)", "1", $str) ;//Convert links starting with http:// and ftp://
$str=str_replace(LINKttp://,http://,$str);
$str = ereg_replace("([ _.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})","1", $str); //Convert email address
return $str;
}
?>