有人可以出于某种原因请求帮助我可以回复并在我的导出函数中设置文件和部门变量但是当我尝试在exportdata中调用它们时它们是空的。
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;
}
}
答案 0 :(得分:2)
你的问题在这里:
public function exportdata() {
return $this->file;
return $this->department;
echo $this->department;
}
您返回的值$this->file
没有回显。
如果您尝试echo $myCustomersController->exportdata()
,您会看到它回显$this->file
如果您想echo
,请删除return
s
public function exportdata() {
echo $this->file;
echo $this->department;
}