Home > php教程 > php手册 > 一个修改过的自动转换url和mail的函数,功能强大

一个修改过的自动转换url和mail的函数,功能强大

WBOY
Release: 2016-06-13 10:24:20
Original
944 people have browsed it

可以转换以http和ftp开头的
还有mail的
还有www开头的
很好的噢

function enable_urls($str){
$str = ereg_replace("(www.[a-zA-Z0-9@:%_.~#-?&]+)", " \1", $str);// 自动转化www开头的链接
$str = ereg_replace("(((f|ht){1}tp://)[a-zA-Z0-9@:%_.~#-?&]+)", "\1", $str);//转化http://开头和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);// 转化邮件地址
return $str;
}
?>

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template