获取控制器名/动作名

在 控制器 里面

1 $controllerID = Yii::$app->controller->id;

2 $actionID = Yii::$app->controller->action->id;

在 视图 里面

1$controllerID = Yii::$app->controller->id;

2$actionID = Yii::$app->controller->action->id;
时间: 2024-08-09 15:49:31

获取控制器名/动作名的相关文章

获取文件名的扩展名

文件名类型有:http://localhost/code/loginfile/index.ini.php?username=aaa E:\xampp\php/login.php login.php function file_extension($url) { //第一步:判断是否有问号"?" $file="";  //存储整个文件名称 if (strstr($url,"?")){ list($file)=explode("?"

JavaScript使用构造函数获取变量的类型名

在JavaScript中,如何准确获取变量的类型名是一个经常使用的问题. 但是常常不能获取到变量的精确名称,或者必须使用jQuery 中的方法,这里 我通过 typeof ,jQuery.type 和 通过构造函数来获取变量类型 这三种方法详细介绍一遍. 希望可以对你提供帮助. 看到题目的第一眼,有些同学可能会想到 typeof 运算符. 使用 typeof 获取基本的类型 在JavaScript语言中,给出了使用 typeof 运算符来获取基本的类型名.(注意不是基本类型) 这是 typeof

获取文件的后缀名 和 Process进程

1.获取文件的后缀名: string hou = Path.GetExtension("wang.txt");//hou=".txt";引用using System.IO;注意"Path"的大写 2.Process进程 1 Process.Start("notepad");//用类名打开记事本,属于静态函数 2 3 //封装我们要打开的文件,但是并不去打开这个文件 4 ProcessStartInfo psi = new Pr

纯JAVA环境获取APK信息(包名,版本,版本号,大小,权限...),纯JAVA语言编写PC端获取APK信息

纯JAVA环境获取APK信息:包名,版本,版本号,大小,权限... 纯Java环境获取APK信息需要两个包:AXMLPrinter2.jar 跟jdom.jar,用于反编译XML和解析XML的 项目目录 这个类是获取APK信息的 public class ApkUtil { private static final Namespace NS = Namespace.getNamespace("http://schemas.android.com/apk/res/android"); @

php : 获取对象的属性名

方案有多种: 一. 使用 get_object_vars() 方法 缺点: 只能显示 public 的 //只显示public的 var_dump(get_object_vars($test)); 处理: 在类中定义一个public 的方法, 外部对象调用即可显示所有属性(除了静态属性之外) function showAllProperties2(){ var_dump(get_object_vars($this)); } 二. 使用ReflectionClass类 能够获取所有的属性名 //显

C++实现获取本机机器名及外网IP代码

#include "stdafx.h" #include <WINSOCK2.H> #include <urlmon.h> #pragma comment(lib, "ws2_32.lib") #pragma comment(lib, "urlmon.lib") #define MAX_SIZE 1024 int GetLocalIP(); int GetInternetIP(); int main(int argc, c

Velocity笔记--使用Velocity获取动态Web项目名的问题

以前使用jsp开发的时候,可以通过request很轻松的获取到根项目名,现在换到使用velocity渲染视图,因为已经不依赖servlet,request等一些类的环境,而Web项目的根项目名又不是写死的,需要动态获取,这时候该怎么办呢,试了网上说了很多种方式,总结一下心得. 第一种:(失败) 在toolbox.xml里配置以下信息: <toolbox scope="request">          <tool key="link" class

获取接入的wifi名

获取接入的wifi名 by 伍雪颖 #import <SystemConfiguration/CaptiveNetwork.h> CFArrayRef supportedInterfaces = CNCopySupportedInterfaces(); if (supportedInterfaces == NULL || CFArrayGetCount(supportedInterfaces) == 0) { if (supportedInterfaces) CFRelease(support

php 获取url的扩展名

方法一: function getExt($url){ $urlinfo = parse_url($url); $file = basename($urlinfo['path']); if(strpos($file,'.') !== false) { $ext = explode('.',$file); return $ext[count($ext)-1]; } return 'no extension'; } 测试的url: echo getExt('http://www.sina.com.c