To Get Current Url
echo Yii::app()->request->requestUri;
Get Action Name
//Anywhere Yii::app()->controller->action->id //Inside Controller public function beforeAction($action) { $actionId = $action->id; .......... }
Get Controller Name
// Anywhere Yii::app()->controller->id
//Inside Controller echo $this->getId();
//Anywhere
ReplyDeleteYii::app()->controller->action->id
//Inside Controller
public function beforeAction($action)
{
$actionId = $action->id;
..........
}
where to write this code??
Hi Tushar, Sometimes you want the current controller name or action name. Yii::app()->controller will give the controller name, action name for anywhwere in your application.
DeleteJust echo Yii::app()->controller->action->id or Yii::app()->controller->id any where