Yii Framework Yiiapp () comprehension _ PHP Tutorial

Source: Internet
Author: User
Yii Framework Yiiapp. Yii Framework Yiiapp () understanding Yii Framework is a pure Object-Oriented Framework. many objects need to be created when an application is accessed during runtime, these understandings of the Yii Framework Yiiapp ()

The Yii Framework is a pure Object-Oriented Framework. during runtime, when an application is accessed, many objects need to be created. these objects call many related methods, to complete a web request.

This Yii: app () is the first object to be created. this object calls related methods and will be used later.

Yii: app () is mainly responsible for some global functional modules. for example, Yii: app ()-> getUser () returns a CWebUser instance (used to express the verification information of the current user ). Because CWebApplication inherits CComponent, Yii: app ()-> getUser () can also write Yii: app ()-> user (see CComponent description, this is the cornerstone of Yii ).

Yii: app () is an instance of the CWebApplication class. Therefore, this class (including the inherited class) can be used for attributes and methods, this object can be used (some methods are the core method for running the system and are not recommended to be called directly ). For example, if there is a method getLayoutPath () in CWebApplication to obtain the layout path, we can do this:

Echo Yii: app ()-> getLayoutPath (); // output D: \ www \ phpernote.com \ protected \ views \ layouts

In addition, the CWebApplication and its parent class CApplication define many usable components for the system. other components such as db, user, session, authManager, and request are not listed in detail.

We can use the above components through Yii: app (), for example:

Echo Yii: app ()-> request-> url; // Obtain the relative url of the current request (/index. php? R = user/login)

Note:

Yii: app ()-> request; creates a request object.

Yii: app ()-> request-> url; the property information in the request class is called. this property does not exist, or call the magic method _ get of the parent class to indirectly call the geturl () method.

Yii: app ()-> user; calls the user verification component (CWebUser). some attributes and methods of CWebUser can be used.

Articles you may be interested in
  • Display text box effects of line numbers, compatible with browsers such as ie and Firefox
  • Detailed analysis on the directory structure of the yii Framework
  • Php builds a simple example of its own MVC framework and provides ideas for your reference only
  • To improve user experience, we must start with analyzing users' visual senses.
  • Select into from prompt Undeclared variable... solution to the error
  • Yii controller action parameter binding
  • What is the php design pattern and how to understand it?
  • Php Output Control: Understanding the differences between ob_flush and flush

Yii Framework is a pure Object-Oriented Framework. many objects need to be created when an application is accessed during runtime, these pairs...

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.