2011-01-07 6 views
1

なぜこれがエラーを投げているのかわかりません - 誰かが問題を見ることができることを願っていますか?変数を設定解除すると致命的なエラーが発生しますか?

$client->set('place', 'home'); 
$client->placeInfo(); 
$client->screen($client->response()); 
$client->unset('place'); 

Fatal error: Call to undefined method Client::unset()...

クライアントクラス

// stores the client data 
private $data = array(); 
// stores the result of the last method 
private $response = NULL; 

/** 
* Sets data into the client data array. This will be later referenced by 
* other methods in this object to extract data required. 
* 
* @param str $key - The data parameter 
* @param str $value - The data value 
* @return $this - The current (self) object 
*/ 
public function set($key, $value) { 
$this->data[$key] = $value; 
return $this; 
} 

/** 
* dels data in the client data array. 
* 
* @param str $key - The data parameter 
* @return $this - The current (self) object 
*/ 
public function del($key) { 
unset($this->data[$key]); 
return $this; 
} 

/** 
* Gets data from the client data array. 
* 
* @param str $key - The data parameter 
* @return str $value - The data value 
*/ 
private function get($key) { 
return $this->data[$key]; 
} 

/** 
* Returns the result/server response from the last method 
* 
* @return $this->response 
*/ 
public function response() { 
return $this->response; 
} 


public function placeInfo() { 
$this->response = $this->srv()->placeInfo(array('place' => $this->get('place'))); 
return $this; 
} 
+0

クラス 'クライアント'とは何ですか? – lonesomeday

+0

'unset()'と何が宣言されていますか? – Dan

+0

$ client = newクライアント($ location、$ wsdl、$ username、$ password); – Dov

答えて

6

あなたの問題の原因は、そのクラスには定義されたメソッドunsetがないことです。 unsetreserved keywordなのでどちらも定義できません。名前としてメソッドを定義することはできません。

public function unset($foo) // Fatal Error 

public function _unset($foo) // Works fine 

編集

...何か他に方法を変更し、呼び出しを変更します。それはだからはあなただけで編集したコードを見てみると、あなたは、 $client->unset('place') $client->del('place')に変更する必要がありますクラス定義のメソッド...

+0

@ircmaxell:ありがとうございます。残りのコードで質問を更新しました。うまくいけば、私はそれに基づいている問題を見ることができます。あなたの答えが残っていれば、私は先に進み、変更を加えてうれしいです。 – Dov

+0

** ircmaxell **にちょっと注意してください。 'if'、' unset'などのメソッド名のために '__call()'にロジックが存在するなら、 '$ obj-> unset($ arg);' – Dan

+0

@Dovを実現することができます私はあなたの編集のために私の答えを編集しました。 – ircmaxell

関連する問題