求$a、$b、$c中的最大值和最小值
更新:HHH   时间:2023-1-7


方法一

<?php

$a=3;

$b=4

$c=5;

echo max($a,$b,$c);

echo "<br/>";

echo min($a,$b,$c);


方法二

<?php

function textmax($a,$b,$c){

$max=$a;

if($max<$b) $max=$b;

if($max<$c) $max=$c;

return $max;

}

$a=3;

$b=4;

$c=5;

echo textmax($a,$b,$c);

?>


方法三

<?php

function textmax($a,$b,$c){

if($a>$b){

  $b=$a; 

}

if($b>$c){

  $c=$b;

}

echo $c;

return $c;

}

textmax(3,4,8);

?>


方法四

<?php

$a=3;$b=4;$c=5;

echo $a>$b?($a>$c?$a:$c):($b>$c?$b:$c);

echo "<br/>";

echo $a<$b?($a<$c?$a:$c):($b<$c?$b:$c);

?>




返回网络安全教程...