こんにちは、他のクラスに含まれている関数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);
}
}
申し訳ありません申し訳ありません、私はちょうどOOPを学び始めています。どのように私はそれらを私のモデルに呼び出すことができますか?今私はモデルpublic function addProcess($ manufacturer){} –
私はユーザー入力をエコーしようとしました。ユーザー入力をエコーしない@arkascha –
@GeninaAnneGabuten申し訳ありませんが、コードを修正して動作させる必要がありました。私はPHPをプログラムするのにしばらく時間がかかりました。 ;-) – arkascha