时间:2021-07-01 10:21:17 帮助过:5人阅读
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@:%_+.~#?&//=]+)','\1\2', $text);
$text = eregi_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})', '\1', $text);
return $text;
}
实现原理:
主要是利用正则原理,匹配网址字符或Email来替换成超级链接。http://www.bkjia.com/PHPjc/321874.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/321874.htmlTechArticle 代码如下:
function makeClickableLinks($text) { $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?lt;a href="\1"\1/a', $text); $text = eregi_replace('([[:...