2013-04-04 56 views
-1

我想寫一個變量來訪問任何操作到同一個控制器。我寫一個共享或全局變量。Kohana Controller操作共享變量

我使用Kohana 3.1。

這是可能的!?我沒有找到任何示例或具有相同問題的人。

回答

0

如何使用類屬性?

<?php defined('SYSPATH') or die('No direct script access.'); 

class Controller_Application extends Controller_Base { 
     public $variable = FALSE; 

     /* This will echo true */ 
     public function action_index() 
     { 
      $this->variable = TRUE; 
      echo Debug::vars($this->variable); 
     } 

     /* This will echo false */ 
     public function action_variable() 
     { 
      echo Debug::vars($this->variable); 
     } 
}