php 链接 怎么可以在自己所发的内容里只要是有http://www.baidu.com就会自动的变成可以链接到http://www.baidu.com的,这个怎么写代码,是要用替换吗?还是要用什么?谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 替换成 <a href="http://www.baidu.com">www.baidu.com</a> 怎么替换啊,我是自己学做一个论坛,就是发帖和回帖里只要有http://www.baidu.com就自动变成链接,而且还有 <a href="http://www.baidu.com"></a>就输不出来,查看代码里有,可是在页面上看不到,这个怎么做? 简单点用正则获取整个链接然后拼装到 <a href 内 a之间没有,我自己做的就输不出,像这个就可以输出 <a href="http://www.baidu.com"></a>也可以看到,我做的就会隐藏了,看不到这个怎么做?要用正则那应该怎么写 借花献佛function autolink($foo) { $foo = eregi_replace ( '(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '<a href="\1" target=_blank rel=nofollow>\1</a>', $foo ); if (strpos ( $foo, "http" ) === FALSE) { $foo = eregi_replace ( '(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '<a href="http://\1" target=_blank rel=nofollow >\1</a>', $foo ); } else { $foo = eregi_replace ( '([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '\1<a href="http://\2" target=_blank rel=nofollow>\2</a>', $foo ); } return $foo;} 正则匹配:<?php$pattern = "/[a-zA-z]+:\/\/[^\s]*/";$content = "想知道详细信息,请点击http://www.baidu.com";preg_match($pattern, $content, $matches);$replace = "<a href={$matches[0]} target='_blank'>百度一下</a>";$newcontent = str_replace($matches[0], $replace, $content);echo $newcontent;?> 简单的说就是我想要做成那种,比如:链接http;//www.网址.com就可以链接到这个“网址”,这个应该怎么写代码?请各位帮帮忙,谢谢! 字符串处理问题 php 判断文件真正类型 的问题 dreamweaver调试php,按F12时,不是出现调试页面,而是出现下载页面。 散分求解!!!!!高手进!! 北京求职 HELP ME! 关于Cookie方面的问题(特别着急!),请高手帮忙 php的小问题 想学php,大家能否推荐几本相关的书以及相关网站? 开发dz插件后台提示错误 请教一个分表优化方案 对与增删改查判断条件的选择疑惑
借花献佛function autolink($foo) {
$foo = eregi_replace ( '(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '<a href="\1" target=_blank rel=nofollow>\1</a>', $foo );
if (strpos ( $foo, "http" ) === FALSE) {
$foo = eregi_replace ( '(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '<a href="http://\1" target=_blank rel=nofollow >\1</a>', $foo );
} else {
$foo = eregi_replace ( '([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '\1<a href="http://\2" target=_blank rel=nofollow>\2</a>', $foo );
}
return $foo;
}
$pattern = "/[a-zA-z]+:\/\/[^\s]*/";
$content = "想知道详细信息,请点击http://www.baidu.com";
preg_match($pattern, $content, $matches);
$replace = "<a href={$matches[0]} target='_blank'>百度一下</a>";
$newcontent = str_replace($matches[0], $replace, $content);
echo $newcontent;
?>
链接
http;//www.网址.com
就可以链接到这个“网址”,这个应该怎么写代码?请各位帮帮忙,谢谢!