为了账号安全,请及时绑定邮箱和手机立即绑定

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 关注
  • 1016 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信