调用其他controller里的变量和方法
2011-07-27 17:26
381 查看
Add this line to /config/main.php (or whatever config file you are using)
example I used in siteController
proof that another controller can access the method
In another controller
用以上方法无法获取到controller里面的方法,
把controller里的方法前加上static设为静态就可以了
'import'=>array( 'application.models.*', 'application.controllers.*', <-- add this line 'application.components.*', ...
example I used in siteController
public function hello() { return 'Hello World'; }
proof that another controller can access the method
In another controller
public function actionIndex() { echo SiteController::hello(); die; ...
用以上方法无法获取到controller里面的方法,
把controller里的方法前加上static设为静态就可以了
相关文章推荐
- Java webservice 调用自定义dll(有其他依赖)方法全解,无需设置环境变量
- spring在controller中,在执行其他方法之前,都先调用@ModelAttribute修饰的方法
- DedeCms Runphp 标签中调用其他变量的方法
- 调用其他类成员变量的方法
- (转)DedeCms Runphp 标签中调用其他变量的方法
- iPhone开发中两个UIViewController间传递变量和调用方法的处理
- 织梦DedeCms Runphp 标签中调用其他变量的方法
- 【Thinking in Java】编写构造器时应注意:尽量避免调用其他非private方法
- 父类与子类之间变量和方法的调用
- vc中调用其他应用程序的方法(函数) winexec,shellexecute ,createprocess
- 浅析jquery ajax异步调用方法中不能给全局变量赋值的原因及解决方法
- 搜索一个类的dispose的调用,把其他类的dispose方法都搜出来了,怎样才能把这个dispose的真正调用搜出来呢?
- 2015.4.28类、对象的初步学习(构建类,成员变量、方法的调用)
- 第二次报错:在spring+springMVC+hibernate中,controller调用service层方法或者dao层方法,报错java.lang.NullPointerException
- 利用Java反射机制调用其他类的main方法 .
- Andorid WebView获取JS全局变量或者调用方法的返回值
- 在Viewpager的子Activity中startActivityForResult调用其他Activity时候遭遇到onActivityResult方法不响应的问题
- jquery 异步调用方法中不能给全局变量赋值的原因及解决办法
- 警告: 最后一个参数使用了不准确的变量类型的 varargs 方法的非 varargs 调用
- js特殊例子--方法内重新定义了变量在后面就会前面的为undifined,后面没有定义就用全局的--各种专业文献上的“闭包”(closure)定义非常抽象,很难看懂。我的理解是,闭包就是能够读取其他函