Get Name of Current Controller and Action in Yii

This is a simple one line piece of code to retrieve the name of the current controller, which is great for making more generic and useful code.

$controllerName = Yii::app()->controller->id;

Related Post

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.