加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

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

发布时间:2020-12-13 20:53:33 所属栏目:PHP教程 来源:网络整理
导读:该函数将 URL 和 E-mail 地址字符串转换为可点击的超级链接,代码下: function makeClickableLinks( $text ) { $text = eregi_replace ( (((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?//=]+) , ahref=11/a , $text ); $text = eregi_replace ( ([[:space:]()[{}])(w

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

  1. function makeClickableLinks($text)  
  2. {  
  3. $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)''<a href="1">1</a>'$text); $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)''1<a href="http://2">2</a>'$text); $text = eregi_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})''<a href="mailto:1">1</a>'$text);  
  4. return $text;  

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读