PHP5默认不支持方法的重载
所以利用__call来实现
class A{
public function test1($parameters){
echo '接收一个参数';
echo "<br/>";
var_dump($parameters);
}
public function test2($parameters){
echo '接收两个参数';
echo "<br/>";
var_dump($parameters);
}
//这里提示一个__call
//_call 当一个对象调用某个方法,而该方法不存在,
//则系统会自动调用__call
function __call($method,$parameters){
var_dump($parameters);
if($method=="test"){
if(count($parameters)==1){
$this->test1($parameters);
}else if(count($parameters)==3)
{
$this->test2($parameters);
}
}
}
}