进入 PHPChina 首页
当前位置:PHPChina 开源社区门户 - PHP编程技巧 - 正文
[字号:  ]

一个正则表达式,判断一段留言中是否有URL,在显示的时候加上超连接

发布时间:2007-6-26 17:51   作者: 网络转载   信息来源:   [我来说两句(1107条)]
 $string = &quot;连接http://www.phpx.com 站点&quot;;<br>
//连接后需要有个空格或回车。<br>
<br>
$string =&nbsp;&nbsp;eregi_replace(&quot;http://([^ ,\r\n]*)&quot;,&quot;&lt;a href=\\0 target=_blank&gt;\\0&lt;/a&gt;&quot;,$string);<br>
$string =&nbsp;&nbsp;eregi_replace(&quot;ftp://([^ ,\r\n]*)&quot;,&quot;&lt;a href=\\0 target=_blank&gt;\\0&lt;/a&gt;&quot;,$string);<br>
<br>
print $string;

字号:   | 推荐给好友

[我来说两句(1107条)]
现在有0人对本文发表评论 查看全部评论>>评论区

 

评分:0

验证码: seccode