亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

YII框架這段代碼是啥意思?是moudles里面view中default中的index.php

YII框架這段代碼是啥意思?是moudles里面view中default中的index.php

Yii
FFIVE 2018-08-09 14:29:42
<?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進來.

查看完整回答
反對 回復 2018-08-12
?
慕后森

TA貢獻1802條經驗 獲得超5個贊

注釋里面不是寫了嗎?

$this DefaultController


查看完整回答
反對 回復 2018-08-12
  • 2 回答
  • 0 關注
  • 1116 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號