我的第一個問題在這裏。PHP OO重試邏輯實現並通過動態方法和參數
的問題是類似這樣的:PHP: Retrying a query a set number of times or until success
嘗試,直到在面向對象的方式取得成功。 這裏例如我想要做的事:
class Creatives {
public function run() {
$auth_token='mypassword';
$id=123123;
$this->retry_till_success ($this->getCreatives, array($auth_token, $id));
print $this->creatives;
}
public function getCreatives($auth_token, $id) {
$this->creatives = $this->campagin->get($auth_token, $id);
}
private function retry_till_success($method, $args) {
do {
$try_again = false;
try {
/* how to call the method with */
/* call user method with params pass */
/* do until success */
} catch (SoapFault $fault) {
if($fault->faultstring== 'couldnt connect to host')
$try_again=true;
}
} while ($try_again);
}
}
我讀到call_user_func,但不知道如果我可以使用它的類裏面, 我需要讓99.9%的成功率在我的電話,任何建議,以實現這一點將是偉大的。 謝謝。
謝謝,但這應該是泛型數字的參數 – stac 2009-06-10 09:17:21