What does the YII framework code mean? Is the index. SegmentFault in the default view in moudles.

Source: Internet
Author: User
{Code...} I want to know where this $ this comes from? There are no classes!

  Breadcrumbs = array ($ this-> module-> id,);?>
  UniqueId. '/'. $ this-> action-> id;?>

This is the view content for action" Action-> id;?> ". The action belongs to the controller" "In" Module-> id;?> "Module.

You may customize this page by editing

I want to know where this $ this comes from? There are no classes!

Reply content:

  Breadcrumbs = array ($ this-> module-> id,);?>
  UniqueId. '/'. $ this-> action-> id;?>

This is the view content for action" Action-> id;?> ". The action belongs to the controller" "In" Module-> id;?> "Module.

You may customize this page by editing

I want to know where this $ this comes from? There are no classes!

Isn't it written in the comment?

$this DefaultController 

$ This in the Yii view refers to the current controller. The specific process is used to view the render method of conroller.
Because the renderer of Yii is used, the renderFile method of the ViewRenderer class is called,
This method receives a $ context parameter, which is actually the Instance Object of the current controller,
Then call the renderInternal method of the controller. This method adds the view File require,
Therefore, in view $ this, the current controller is actually passed in, and then the controller's own method is called to bring in the view File require.

Usedebug_print_backtraceYou can see at first glance

I have an answer, but I have never actually used YII, so I just want to explain it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.