我有,可以採取可變數目的參數的PHP函數(我用func_get_args()
來處理它們)PHP函數 - 調用自與相同(可變數量)參數
class Test {
private $ting = FALSE;
public function test() {
$args = func_get_args();
if ($this->ting) {
var_dump($args);
} else {
$this->ting = TRUE;
$this->test($args); //I want to call the function again using the same arguments. (this is pseudo-code)
}
}
}
此功能是不是遞歸( 「$ ting」變量阻止它多次出現)。
我想讓test()使用它給出的相同參數來調用自己。因此,例如: Test->test("a", "b", "c");
將輸出如下:
array(3) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" }
爲什麼'&$ this'而不只是'$ this'? – fruitcup
個人喜好。無論哪種方式將工作。 – maxton