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设为静态就可以了

相关文章:

  • 2022-12-23
  • 2021-06-14
  • 2022-12-23
  • 2022-12-23
  • 2022-03-10
  • 2022-12-23
  • 2021-10-05
  • 2021-12-01
猜你喜欢
  • 2021-11-30
  • 2021-08-17
  • 2021-04-20
  • 2021-06-13
  • 2022-12-23
  • 2022-12-23
  • 2021-07-05
相关资源
相似解决方案