php - 如何在 yii2 中获取当前 Controller

标签 php yii2

我想在 yii2 中获取当前页面 Controller ? 我如何在 Yii2 中实现这一目标?

在 Yii 1.0 中

Yii::app()->controller->action->id

Yii2 ?

最佳答案

使用此代码

Yii::$app->controller->id

关于php - 如何在 yii2 中获取当前 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27796371/

相关文章:

php gd : image cannot be displayed because it contains errors

php - mysqli_insert_id : What if someone inserts another row just before I call this?

gridview - 从 DataProvider 值 yii2 设置页面标题

constructor - 如何在 Yii2 模型中创建构造函数

php - 我可以在一个 MySQL 查询中使用多个 WHERE 语句吗?

javascript - SSE 加载大量数据并使 AJAX post 请求瘫痪

php - Yii2 高级模板 : Adding stand-alone web pages

javascript - Yii2 activeform ajax 提交和验证

php - 前导 0 不显示在 mysql 表结果中

php - 如何在 YII2 中将类添加到 ActiveField 的 form-group div?