你好,我想問一下如何從函數postData()中獲得$ manufacturer和$ id,這個函數包含在其他類中。所以我可以將它傳遞給我的模型。謝謝。如何使用extend從其他類訪問變量?
class postDataManager{
public function postData(){
$manufacturer = $_POST['manufacturer'];
$id = $_POST['id'];
}
}
class manufactureController extends postDataManager{
private $model;
public function __construct(){
$this->model = new manufacturerModel();
$postDataManager= new postDataManager();
}
public function addManufacturer(){ //get the add function
//here i need access for the variable $manufaturer from class postData function
$this->model->addProcess($manufacturer);
}
public function updateManufacturer(){ //get the update function
//here i need access for the variable $manufaturer and $id from class postData function
$this->model->updateProcess($id, $manufacturer);
}
}
對不起,我剛剛開始學習面向對象。我怎麼可以稱他們爲我的模型..就像現在我在模型公共職能addProcess($製造商){} –
我試圖回聲用戶輸入。它不反映用戶輸入@arkascha –
@GeninaAnneGabuten我很抱歉,我不得不修改代碼,使其工作。過了一段時間我爲PHP編程。 ;-) – arkascha