class AdminAction extends Action { private $uid_t; public function addassets(){ $uid = I('id'); $this->uid = $uid; $this->setuid_t($uid); $this->display(); } public function setuid_t($uid){ $this->uid_t = $uid; } public function getuid_t(){ return $this->$uid_t; } public function actaddassets(){ $data['uid'] = $this->getuid_t(); $data['assets_name'] = I('assets_name'); if ($id=M('device')->add($data)) { $this->redirect('index'); }else{ echo M('device')->getLastsql();exit; $this->redirect('addassets'); } }
A variable ID is obtained from the front end in Addassets (), stored in the local UID, and then the Display addassets.html page. However, this page does not use the UID variable, and the next page (Addassets.html has a button to jump to actaddassets.html) actaddassets.html need to use the UID this variable. The UID is not available in Actaddassets () by the above method.
First study, but also to the great God guidance, thank you!
Reply content:
class AdminAction extends Action { private $uid_t; public function addassets(){ $uid = I('id'); $this->uid = $uid; $this->setuid_t($uid); $this->display(); } public function setuid_t($uid){ $this->uid_t = $uid; } public function getuid_t(){ return $this->$uid_t; } public function actaddassets(){ $data['uid'] = $this->getuid_t(); $data['assets_name'] = I('assets_name'); if ($id=M('device')->add($data)) { $this->redirect('index'); }else{ echo M('device')->getLastsql();exit; $this->redirect('addassets'); } }
A variable ID is obtained from the front end in Addassets (), stored in the local UID, and then the Display addassets.html page. However, this page does not use the UID variable, and the next page (Addassets.html has a button to jump to actaddassets.html) actaddassets.html need to use the UID this variable. The UID is not available in Actaddassets () by the above method.
First study, but also to the great God guidance, thank you!
class AdminAction extends Action { static $uid_t=""; public function addassets(){ $uid = I('id'); $this->uid = $uid; self::$uid_t = $uid; $this->display(); //echo self::$uid_t; } public function actaddassets(){ echo self::$uid_t; /* $data['uid'] = $uid; $data['assets_name'] = I('assets_name'); if ($id=M('device')->add($data)) { $this->redirect('index'); }else{ echo M('device')->getLastsql();exit; $this->redirect('addassets'); } */ }
Do some experimenting, define a static $uid_t, and then do not output the page in Addassets (), Directly echo Self:: $uid _t is a value, but then echo self again in Actaddassets ():: $uid _ T is not worth it. Why is this ...? Thank you!