|
Posted by Michael Jack on 10/11/05 11:50
In the program below, what is the meaning/use of
the question mark (?gcd) and the colon (:$a) after the return statement? Any
explanation will be appreciated.
<?
$x=32;
$y=80;
function gcd($a, $b)
{ return ($b>0)?gcd($b,$a%$b):$a;}
$val=gcd($x, $y);
print "The greatest common denominator of $x and $y is $val";
?>
This recursive program is used to find the greatest common denominator of 2
numbers.
TIA
Navigation:
[Reply to this message]
|