您的位置:首页 > 其它

调用其他controller里的变量和方法

2011-07-27 17:26 381 查看
Add this line to /config/main.php (or whatever config file you are using)

'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设为静态就可以了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐