Refer to the controller within view in yii2

We can get the controller object by the expression $this->context. And as a result, it is possible to access any properties or methods of the controller in the view, such as the controller ID shown in the following:

The controller ID is: <?= $this->context->id ?>

Running low on budget? Get the best Shared hosting at an Affordable Rate!