有誰知道如何訪問公共控制器變量,它已被其他功能更新的價值? 代碼示例 控制器訪問公共變量的值笨控制器
class MyController extends CI_Controller {
public $variable = array();
function __construct() {
parent::__construct();
}
function index(){
$this->variable['name'] = "Sam";
$this->variable['age'] = 19;
}
function another_function(){
print_r($this->variable);
}
}
當我打電話another_function()我得到一個空數組..可能是什麼問題呢? 任何幫助將apreciated ..當你到那個特定頁面
愚蠢的問題,你有沒有所謂的指數()? – 2011-06-16 12:46:39
這應該工作,它看起來像e'index()'沒有被調用。 – Dunhamzzz 2011-06-16 12:46:44