当一个类中有非静态方法被 self:: 调用时,系统会自动将这个方
时间:2007-01-17 来源:liuxingyuyuni
?php
/**
* @author bianjiang
* @todo 练习静态方法调用/
* @desc
* 求最大值
*/
class Math
{
public function Max($first, $second)
{
return ($first > $second)?$first:$second;
}
public static function Max3($first, $second, $third)
{
$one = self::Max($first, $second);
$two = self::Max($second, $third);
$res = self::Max($one, $two);
return $res;
}
}
$a = 1;
$b = 2;
$c = 3;
echo Math::Max3($a, $b, $c);
?>
虽然正确执行了,可是PHP进行了转换所以影响了程序执行的时间,不要这样做。。。。。。
就当这是错误的就好
相关阅读 更多 +