我使用此代码来制作纯文本超链接。从纯文本创建超链接
$text = eregi_replace('(((f|ht){1}tp://)[[email protected]:%_\+.~#?&//=]+)',
'<a target="_blank" href="\\1">\\1</a>', $text);
$text = eregi_replace('(((f|ht){1}tps://)[[email protected]:%_\+.~#?&//=]+)',
'<a target="_blank" href="\\1">\\1</a>', $text);
$text = eregi_replace('([[:space:]()[{}])(www.[[email protected]:%_\+.~#?&//=]+)',
'\\1<a target="_blank" href="http://\\2">\\2</a>', $text);
$text = eregi_replace('([_\.0-9a-z-][email protected]([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})',
'<a target="_blank" href="mailto:\\1">\\1</a>', $text);
但它不工作的时候文本www.domain.com或domain.com或subdomain.domain.com
我怎样才能使它与他们合作?
感谢
可能的重复[如何链接到一个字符串与PHP的url?](http://stackoverflow.com/questions/507436/how-do-i-linkify-urls-in-a-string-with- php) – 2011-03-05 15:30:39