$这可以如何引用yii2中布局文件中的yii \ web \ View类的实例?

$这可以如何引用yii2中布局文件中的yii \ web \ View类的实例?

问题描述:

Documentation comments in yii2 say us that $this pointer in layout files refer to yii\web\View, but I'm confused that how this pointer can used outside of his class!?

yii2中的文档注释告诉我们布局文件中的 $ this code>指针引用 yii \ web \ View code>,但我很困惑这个指针如何在他的课外使用!? p> div>

If you debug the code deep enough, you will see this https://github.com/yiisoft/yii2/blob/master/framework/base/View.php#L341

They require a file in the method, that is why $this point to class :)