选择语言 :

 Core_Text::auto_link_emails

Converts text email addresses into links. Existing links will not be altered.

echo Text::auto_link_emails($text);

This method is not foolproof since it uses regex to parse HTML.
string Core_Text::auto_link_emails( string $text )
uses
HTML::mailto

参数列表

参数 类型 描述 默认值
$text string Text to auto link
返回值
  • string
File: ./core/classes/text.class.php
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);
}