php方法重载
php中的方法重载
<?php
namespace __0802;
class Demo4
{ //普通方法重载
//$name 是要重载的名
//$arguements 是要重载的参数组成的数组
public function __call($name, $arguments)
{
// TODO: Implement __call() method.
return '方法名:'.$name.'<br>参数列表:'.'<pre>'.print_r($arguments,true);
}
//静态方法重载
public static function __callStatic($name, $arguments)
{
// TODO: Implement __callStatic() method.
return '方法名:'.$name.'<br>参数列表:'.'<pre>'.print_r($arguments,true);
}
}
$obj = new Demo4();
echo $obj->getInfo(10,20,30);
echo '<hr>';
echo Demo4::getInfo1('php','java','css');

浙公网安备 33010602011771号