首页 > 开发 > PHP > 正文

列个正则表达式,判断一段留言中的http;//www.phpx.com,在显示的时候加上超连接。

2024-05-04 22:55:25
字体:
来源:转载
供稿:网友
$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;

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表