Converts text email addresses into links. Existing links will not be altered.
echo Text::auto_link_emails($text);
string Core_Text::auto_link_emails( string $text )
参数列表
参数 类型 描述 默认值 $text
string
Text to auto link
string
public static function auto_link_emails($text)
{
// Find and replace all email addresses that are not part of an existing html mailto anchor
// Note: The "58;" negative lookbehind prevents matching of existing encoded html mailto anchors
// The html entity for a colon (:) is : or : or : etc.
return preg_replace_callback('~\b(?<!href="mailto:|58;)(?!\.)[-+_a-z0-9.]++(?<!\.)@(?![-.])[-a-z0-9.]+(?<!\.)\.[a-z]{2,6}\b(?!</a>)~i', 'Text::_auto_link_emails_callback', $text);
}