<?php/* @var $this DefaultController $this是從哪來的? */$this->breadcrumbs=array( $this->module->id,);?><h1><?php echo $this->uniqueId . '/' . $this->action->id; ?></h1><p>This is the view content for action "<?php echo $this->action->id; ?>".The action belongs to the controller "<?php echo get_class($this); ?>"in the "<?php echo $this->module->id; ?>" module.</p><p>You may customize this page by editing <tt><?php echo __FILE__; ?></tt></p>
2 回答

Cats萌萌
TA貢獻1805條經驗 獲得超9個贊
Yii view 里面的$this 是指當前controller,具體過程去看conroller的render方法.
因為是用Yii自身的renderer,所以調用的是ViewRenderer類的renderFile方法,
這方法接收一個$context參數,其實傳的就是當前controller的實例對象,
然后再調這個controller的renderInternal方法,這個方法把view文件require進來了,
所以在view的$this其實是把當前controller傳進來,然后調用傳進來的controller的自身方法,把view文件require進來.
- 2 回答
- 0 關注
- 1116 瀏覽
添加回答
舉報
0/150
提交
取消