打印

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

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

 $string = &quot;连接http://www.phpx.com 站点&quot;;<br>
//连接后需要有个空格或回车。<br>
<br>
$string =&nbsp;&nbsp;eregi_replace(&quot;http://([^ ,\r\n]*)&quot;,&quot;&lt;a href=http://www.phpchina.com/\\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=http://www.phpchina.com/\\0 target=_blank&gt;\\0&lt;/a&gt;&quot;,$string);<br>
<br>
print $string;

TOP

当前时区 GMT-4, 现在时间是 2008-10-12 18:17
ComePlay8.Com
Powered by Discuz! 6.0.0 © 2001-2007 Comsenz Inc.
Processed in 0.082011 second(s), 10 queries, Gzip enabled
TOP
清除 Cookies - 联系我们 - 来玩吧 - Archiver - WAP
Designed By Discuz! Support Team