What does $options = []; stands for?

Hello all,

I would like to know what does this $options = []; stands for please in the generated model from Gii. Why is it [] empty?




  public function getUserLink()

    {

        $url = Url::to(['user/view', 'id'=>$this->UserId]);

        $options = [];

        return Html::a($this->getUserName(), $url, $options);



Thank you,

Ben

It is a property (ARRAY) with parameters to make a link

http://www.yiiframework.com/doc-2.0/yii-helpers-basehtml.html#a()-detail

Thank you so much Gustavo!

Ben

Also: http://php.net/manual/en/language.types.array.php (See the example referring to PHP 5.4)

I have worked in so many legacy PHP applications that I forget the "[]" shorthand all the time, and constantly type out "array()".

$options in every case that I’ve seen so far are HTML options. So in your case it would be <a></a> html options.

i.e.


<a class="someCssClass" rel="nofollow">

would be


['class'=>'someCssClass', 'rel'=>'nofollow']

here are the HTML Options list.

so


Html::a($this->getUserName(), $url, $options);

configured would be something like


Html::a($this->getUserName(), 'someurl.com', ['class'=>'someCssClass', 'id'=>'someID', 'rel'=>'nofollow']);

outputs a html "a" link

the above is the same as




<a href="someurl.com" class="test" id="someID" rel="nofollow">UserName</a>

in basic HTML

Also, whenever you see $clientOptions they are the plugins public configurable options.