<?php
class test12
{
public function __call($name, $arguments)
{
if ($name === 'test'){
if(count($arguments) === 1 ){
return $this->test1($arguments[0]);
}
if(count($arguments) === 2){
return $this->test2($arguments[0], $arguments[1]);
}
if(count($arguments) === 3){
return $this->test3($arguments[0], $arguments[1],$arguments[2]);
}
}
}
private function test1($data1)
{
echo $data1;
}
private function test2($data1,$data2)
{
echo $data1.' '.$data2;
}
private function test3($data1,$data2,$data3)
{
echo $data1.' '.$data2.$data3;
}
}
$test = new test12();
$test->test('one argument'); //echoes "one argument"
$test->test('two','arguments');
$test->test('three','om','test'); //echoes "two arguments"
?>
output:
one argumenttwo argumentsthree omtest
class test12
{
public function __call($name, $arguments)
{
if ($name === 'test'){
if(count($arguments) === 1 ){
return $this->test1($arguments[0]);
}
if(count($arguments) === 2){
return $this->test2($arguments[0], $arguments[1]);
}
if(count($arguments) === 3){
return $this->test3($arguments[0], $arguments[1],$arguments[2]);
}
}
}
private function test1($data1)
{
echo $data1;
}
private function test2($data1,$data2)
{
echo $data1.' '.$data2;
}
private function test3($data1,$data2,$data3)
{
echo $data1.' '.$data2.$data3;
}
}
$test = new test12();
$test->test('one argument'); //echoes "one argument"
$test->test('two','arguments');
$test->test('three','om','test'); //echoes "two arguments"
?>
output:
one argumenttwo argumentsthree omtest