文件名称:PHP实现类的多态帮助类ClassUtil
文件大小:2KB
文件格式:PHP
更新时间:2014-03-17 14:42:15
php帮助类 实现多态
#PHP实现类的多态帮助类ClassUtil
#PHP实现函数多态的帮助类ClassUtil
使用举例:
class calc {
public function __construct()
{
$args=func_get_args();
ClassUtil::callMethodForArgs($this,$args);
}
public function construct_()
{
echo ("0 args function is called
");
}
public function construct_number($num)
{
echo "arg 1 function is called:".$num*$num."
";
}
public function construct_number_number($n1,$n2)
{
echo "arg 2 function is called:".$n1*$n2."
";
}
public function construct_string_number($s,$n)
{
echo"args is string and number function is called".$s.$n;
}
}
$c1= new calc();
$c2= new calc(4);
$c3= new calc(4,5);
$c4= new calc("teststring",100);
$c5= new calc("abc","test no this two string function");