Home  >  Article  >  php教程  >  网址字符串转换成超级链接PHP代码

网址字符串转换成超级链接PHP代码

WBOY
WBOYOriginal
2016-06-13 10:03:431443browse

该函数将 URL 和 E-mail 地址字符串转换为可点击的超级链接。

 代码如下 复制代码
function makeClickableLinks($text)
{
$text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)', '1', $text); $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)', '12', $text); $text = eregi_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})', '1', $text);
return $text;
}
Statement:
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