有人可以請求幫助,出於某種原因,我可以在我的導出函數中回顯並設置文件和部門變量,但是當我嘗試在exportdata中調用它們時,它們爲空。OOP公共變量問題
Class customersController Extends baseController {
public $file;
public $department;
public function export() {
$this->registry->template->title = 'Ainsworthstudio - Export Customer Info';
$this->registry->model->createModel('db', 'db');
$this->registry->model->createModel('customers', 'customers');
$this->registry->model->getModel('db')->addConnection("localhost", "sdgsdg", "sdg0", "sdg");
$data = $this->registry->model->getModel('customers')->getDepartments();
while(list($k, $v)=each($data))
$$k = $v;
$this->registry->template->departments = $data;
$this->registry->template->show('customers_export');
}
public function exportcheck() {
if(!empty($_POST['filename'])) {
$this->file = $_POST['filename'];
$this->department = $_POST['depart'];
echo "<div class='error_message'>Exported Successfully</div>";
echo $this->file;
echo $this->department;
echo 'success';
} else {
echo "<div class='error_message'>Wrong Username or Password</div>";
exit();
}
}
public function exportdata() {
return $this->file;
return $this->department;
echo $this->department;
}
}
它會是非常不錯的,如果你能縮進它呼應
$this->file
值的編碼和刪除不必要的代碼,因此願意幫助您的人們可以更輕鬆地閱讀它。其次,你有沒有設置這些屬性? – deceze 2011-03-25 05:48:46
是的,清除代碼並顯示你如何使用它。 PS。它是一個CI框架,對嗎? – biakaveron 2011-03-25 06:10:39
對不起,我正在構建的框架,我仍然必須簡化很多東西到功能我只是想讓所有工作 – 2011-03-25 17:21:35