public static function createLinkTag($link, $text = '', $attributes = [])
    {
        $linkTag = '<a href="'.str_replace(['"', "'"], [urlencode('"'), urlencode("'")], $link).'"';

        if (self::validateEmail($link)) {
            $linkTag = '<a href="mailto:'.$link.'"';
        }

        if (!isset($attributes['title']) && !empty($text)) {
            $linkTag .= ' title="'.str_replace('"', '', strip_tags($text)).'" ';
        }

        if (empty($text)) {
            $text = $link;
        }

        $attr = trim(self::arrayToString($attributes));
        $linkTag .= $attr.'>'.htmlspecialchars($text, ENT_QUOTES, 'UTF-8').'</a>';

        return $linkTag;
    }
public static function createLinkTag($link, $text = '', $attributes = [])
    {
        $linkTag = '<a href="'.str_replace(['"', "'"], [urlencode('"'), urlencode("'")], $link).'"';

        if (self::validateEmail($link)) {
            $linkTag = '<a href="mailto:'.$link.'"';
        }

        if (!isset($attributes['title']) && !empty($text)) {
            $linkTag .= ' title="'.str_replace('"', '', strip_tags($text)).'" ';
        }

        if (empty($text)) {
            $text = $link;
        }

        $attr = trim(self::arrayToString($attributes));
        $linkTag .= $attr.'>'.htmlspecialchars($text, ENT_QUOTES, 'UTF-8').'</a>';

        return $linkTag;
    }
public static function createLinkTag ( $ link , $ text = '' , $ attributes = [ ] ) { $ linkTag = '<a href="' . str_replace ( [ '"' , "'" ] , [ urlencode ( '"' ) , urlencode ( "'" ) ] , $ link ) . '"' ; if ( self :: validateEmail ( $ link ) ) { $ linkTag = '<a href="mailto:' . $ link . '"' ; } if ( ! isset ( $ attributes [ 'title' ] ) && ! empty ( $ text ) ) { $ linkTag .= ' title="' . str_replace ( '"' , '' , strip_tags ( $ text ) ) . '" ' ; } if ( empty ( $ text ) ) { $ text = $ link ; } $ attr = trim ( self :: arrayToString ( $ attributes ) ) ; $ linkTag .= $ attr . '>' . htmlspecialchars ( $ text , ENT_QUOTES , 'UTF-8' ) . '</a>' ; return $ linkTag ; }
Create HTML A Tag.

@param string $link       URL or Email address
@param string $text       Optional, If link text is empty, $link variable value will be used by default
@param array  $attributes Optional, additional key/value attributes to include in the IMG tag

@return string containing complete a tag
Create HTML A Tag .