public function beforeAction($action) { if ($action->id == 'private') { if (Yii::$app->user->isGuest) { return $this->redirect(['site/login']); } } return parent::beforeAction($action); }
public function beforeAction($action) { foreach ($_GET as $key => $value) { $_GET[$key] = strtolower($value); } foreach ($_POST as $key => $value) { $_POST[$key] = strtolower($value); } return parent::beforeAction($action); }Package/Library: Yii Framework The beforeAction method is commonly found in many PHP controller frameworks, including Yii, Laravel, CodeIgniter, and CakePHP. The examples shown here are using the Yii framework.