1
我有下面的代碼,我試圖找到一個解決方案:PHP變量委託功能
<?php
class t1 {
public $response = array();
public $request = array();
public function getRequest() {
return $this->request;
}
public function getResponse() {
return $this->response;
}
}
class t2 extends t1 {
public function run($f) {
$this->response = $f($this);
return $this;
}
}
$delegate = function($c)
{
// PLACEHOLDER
// This is the only place to update test code
// It's not allowed to modify any other section of this code
};
$t = new t2();
print_r(array("request" => $t->run($delegate)->getRequest(), "response" => $t->getResponse()));
?>
我假設$代表是一個動態的功能。任何人都可以通過這個來引導我。
我想在佔位符應爲:
你的問題是什麼? – ComFreek