Converts text anchors into links. Existing links will not be altered.
echo Text::auto_link_urls($text);
string Core_Text::auto_link_urls( string $text )
参数列表
参数 类型 描述 默认值 $text
string
Text to auto link
string
343344345346347348349350public
static
function
auto_link_urls(
$text
)
{
// Find and replace all http/https/ftp/ftps links that are not part of an existing html anchor
$text
= preg_replace_callback(
'~\b(?<!href="|">)(?:ht|f)tps?://\S+(?:/|\b)~i'
,
'Text::_auto_link_urls_callback1'
,
$text
);
// Find and replace all naked www.links.com (without http://)
return
preg_replace_callback(
'~\b(?<!://|">)www(?:\.[a-z0-9][-a-z0-9]*+)+\.[a-z]{2,6}\b~i'
,
'Text::_auto_link_urls_callback2'
,
$text
);
}