Yii вопросы и ответы для интервью
Вопрос 21. How to handle form submissions in Yii?
You can handle form submissions in Yii by using the CActiveForm widget and processing the form data in the controller action.
Example:
// if(isset($_POST['Model'])) { $model->attributes=$_POST['Model']; if($model->save()) { // success action } }
Вопрос 22. Explain Yii's CSRF protection.
Yii includes built-in CSRF protection to prevent cross-site request forgery attacks. It can be enabled by adding the 'csrf' filter to controller actions.
Example:
// public function filters() { return array('csrf', 'accessControl'); }
Вопрос 23. What is Yii's asset manager?
The asset manager in Yii is responsible for managing and publishing asset files such as CSS, JavaScript, and images.
Example:
// $baseUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.assets'));
Вопрос 24. How does Yii handle authentication?
Yii provides various authentication methods, including RBAC, password-based authentication, and integration with external authentication systems.
Example:
// Yii::app()->user->login($identity);
Вопрос 25. What is Yii's event handling?
Yii's event handling allows you to attach event handlers to components and execute custom code when specific events occur.
Example:
// $component->onEvent = function($event) { // handle event };
Самое полезное по оценкам пользователей: