Back to HTMLHelper class

Method link

public static string
(mixed $url, mixed $text, mixed $attribs = null)
Write a `<a>` element
Parameters
  • string $url The relative URL to use for the href attribute
  • string $text The target attribute to use
  • array|string $attribs Attributes to be added to the `<a>` element
Returns
  • string
Since
  • 1.5
Class: HTMLHelper
Project: Joomla

Method link - Source code

/**
 * Write a `<a>` element
 *
 * @param   string        $url      The relative URL to use for the href attribute
 * @param   string        $text     The target attribute to use
 * @param   array|string  $attribs  Attributes to be added to the `<a>` element
 *
 * @return  string
 *
 * @since   1.5
 */
public static function link($url, $text, $attribs = null)
{
    if (\is_array($attribs)) {
        $attribs = ArrayHelper::toString($attribs);
    }
    return '<a href="' . $url . '" ' . $attribs . '>' . $text . '</a>';
}