yii\helpers\BaseHtml::a PHP Метод

a() публичный статический Метод

Generates a hyperlink tag.
См. также: yii\helpers\Url::to()
public static a ( string $text, array | string | null $url = null, array $options = [] ) : string
$text string link body. It will NOT be HTML-encoded. Therefore you can pass in HTML code such as an image tag. If this is coming from end users, you should consider [[encode()]] it to prevent XSS attacks.
$url array | string | null the URL for the hyperlink tag. This parameter will be processed by [[Url::to()]] and will be used for the "href" attribute of the tag. If this parameter is null, the "href" attribute will not be generated. If you want to use an absolute url you can call [[Url::to()]] yourself, before passing the URL to this method, like this: ```php Html::a('link text', Url::to($url, true)) ```
$options array the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered.
Результат string the generated hyperlink
    public static function a($text, $url = null, $options = [])
    {
        if ($url !== null) {
            $options['href'] = Url::to($url);
        }
        return static::tag('a', $text, $options);
    }

Usage Example

Пример #1
0
 /**
  * Overwritten method. By default i18n is used.
  * @inheritdoc
  */
 public static function a($text, $url = null, $options = [])
 {
     if (isset($options['raw']) and $options['raw'] == true) {
         unset($options['raw']);
         return parent::a($text, $url, $options);
     } else {
         unset($options['raw']);
         return parent::a(Yii::t('app', $text), $url, $options);
     }
 }
All Usage Examples Of yii\helpers\BaseHtml::a