Html::link PHP Method

    static function link($text, $url, $options = array())
    {
        if (isset($options['confirm'])) {
            if (!empty($options['confirm'])) {
                $confirmMessage = $options['confirm'];
                $confirmAction = '';
                if (isset($options['confirmaction'])) {
                    if (!empty($options['confirmaction'])) {
                        $confirmAction = $options['confirmaction'];
                    }
                    unset($options['confirmaction']);
                }
                $options['onclick'] = Html::getConfirmationOnActionScript($options['confirm'], $confirmAction);
            }
            unset($options['confirm']);
        }
        // Do not escape title if it is an image
        if (!preg_match('/^<img.*/', $text)) {
            $text = Html::cleanInputText($text);
        }
        return sprintf('<a href="%1$s" %2$s>%3$s</a>', Html::cleanInputText($url), Html::parseAttributes($options), $text);
    }

Usage Example

Example #1
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     $this->separator = '<span class="divider">' . $this->separator . '</span>';
     if ($this->homeLink === null) {
         $this->homeLink = Html::link(\Yii::t('zii', 'Home'), \Yii::app()->homeUrl);
     }
 }
All Usage Examples Of Html::link
Html