Getting Current Controller ID in Yii(在 Yii 中获取当前控制器 ID)
问题描述
我想获取处理当前操作的当前控制器名称.但在我的情况下我将在我的布局文件中的 main.php 中查找当前控制器.
I want to get the current controller name that handles the current action. but the in my case I will look for the current controller in my main.php in my layout files.
这是我的目录结构的小视图,让您了解我的布局文件在哪里以及我将在其中放置代码以搜索控制器名称的文件
this is my small view of my directory structure to give you an idea where is my layout files and the file where i will put my codes in searching of my controller name
- /受保护
- /主题
- /mylayout
- /布局
- main.php
- column1.php
- column2.php
- index.php
这可能吗?我正在尝试以下代码,但我没有得到我当前的控制器名称...
Is this possible? im trying the following codes but i failed to get my current controller name...
echo Yii::app()->controller->getId; echo Yii:app()->getController->id; echo Yii:app()->controller->uniqueID;谢谢
推荐答案
getUniqueId();?>这将显示当前控制器
这篇关于在 Yii 中获取当前控制器 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
- /布局
- /mylayout
本文标题为:在 Yii 中获取当前控制器 ID
基础教程推荐
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何替换eregi() 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
