Yii 面试题与答案
问题 6. Explain Yii's asset management.
Yii provides asset management to efficiently manage and publish CSS, JavaScript, and image files, improving application performance.
Example:
// $baseUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.assets'));
问题 7. What is Yii's filter in controllers?
Filters in Yii allow you to perform actions before and after controller actions are executed, providing a way to modify the request or response.
Example:
// public function filters() { return array('accessControl', 'postOnly + delete'); }
问题 8. Explain Yii's RBAC (Role-Based Access Control).
Yii's RBAC system allows you to manage access control through roles, permissions, and assignments, providing a flexible way to control user access to actions and resources.
Example:
// $auth = Yii::app()->authManager; $role = $auth->createRole('admin'); $auth->assign('admin', 'user123');
问题 9. How does Yii handle form validation?
Yii uses model-based form validation. You define validation rules in the model, and Yii automatically validates input data against these rules.
Example:
// public function rules() { return array('username, password', 'required'); }
问题 10. Explain Yii's database migration.
Yii's database migration allows you to version control and apply changes to the database schema in a structured and organized way.
Example:
// $ yii migrate/create create_user_table
用户评价最有帮助的内容: