我正在与代码作斗争:
$worker = new Worker(); // :|
$worker->addWorker;
//testing
//testing
// $_SESSION['worker']->addWorker();
echo $_POST['name'];
echo $worker->name;
最后两行应该显示相同的值。类中的 assign 方法如下所示:
public function addWorker()
{
$this->name = $_POST['name'];
$this->surname = $_POST['surname'];
$this->dob = $_POST['dob'];
$this->skills = $_POST['skills'];
$this->postcode = $_POST['postcode'];
$this->street = $_POST['street'];
$this->email = $_POST['email'];
$this->tel = $_POST['tel'];
$this->erefnumber = $_POST['erefnumber'];
}
我已经声明了类 Worker 属性。问题是我没有任何错误, $worker->name 只是给出了任何东西。echo $_POST['name'] 工作正常。