Google News
logo
Yii framework - Interview Questions
What are Views in Yii framework?
Views are responsible for presenting models in the format that end users desire. In general,
 
* Views should mainly contain presentational code, such as HTML and simple PHP code to traverse, format, and render data.

* It should avoid containing code that performs explicit DB queries. Such code is better placed in models.

* This is the controller's job. It should avoid direct access to $_GET, $_POST, or other similar variables representing the end-user request. The view should be focused on the display and layout of the data provided to it by the controller or model, but not attempting to access request variables or the database directly.

* It may access properties and methods of controllers and models directly. However, It should be done only for presentation.
Advertisement