You are here: Re: How to use ? and : « All PHP « IT news, forums, messages
Re: How to use ? and :

Posted by lallous on 10/11/05 12:03

Hello

Check the manual for: "ternary operator"

In short:

C = cond ? A : B

as if:

if (cond) C = A else C = B

Regards,
Elias
"Michael Jack" <michael@jack2005.com> wrote in message
news:difude$ksh$1@domitilla.aioe.org...
> 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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация