我想要一個函數,然後多次使用不同的參數。獲取多次調用函數時添加的信息
例如:
<?php
class Test {
var $test;
public function func($val) {
$this->test = $val;
}
public function buildFunc() {
if(!empty($this->test)) {
$ret = $this->test;
}
return $ret;
}
}
?>
然後調用頁面上:
$test = new Test;
$test->func("test1");
$test->func("test2");
echo $test->buildFunc();
然後打印屏幕上的TEST2。我希望它能打印出它們兩個。
請改用數組? – hjpotter92
不清楚你想要什麼。你的函數調用如何? –
你想要$ test-> buildFunc();打印'test1和test2'? – knightrider