我有一個控制器與多個功能,其中有一個變量。我想從另一個函數訪問這些變量。有任何想法嗎?cakephp,如何將變量存儲在另一個函數內可重用?
class RoomsController extends AppController {
public $helpers = array('Js' => 'Jquery');
public $components = array('RequestHandler');
function test1(){
$balcony = $_REQUEST['qwe'];
$this->set('qwe',$qwe);
}
function test2() {
$occy = $_REQUEST['wer'];
$this->set('wer',$wer);
}
function test3() {
$deck = $_REQUEST['ert'];
$this->set('ert',$ert);
}
function success() {
// i want to use $qwe, $wer and $ert here
}
有關如何做到這一點的任何想法?我是否需要設置全局變量public $qwe;
?
感謝
你什麼時候調用'success()'? *通常*你不會在任何其他控制器動作的同一個請求中調用它,所以問題*應該是沒有意義的。 – deceze
你可以使用會話 - > http://book.cakephp.org/view/1312/write – Rikesh