Re: How to use ? and : in a program
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: How to use ? and : in a program

From: Erwin Moller <since_humans_read_this_I_am_spammed_too_much@spamyourself.com>
Date: Tue Oct 11 2005 - 13:21:14 CEST

Oli Filth wrote:

> Erwin Moller said the following on 11/10/2005 10:05:
>> Michael Jack wrote:
>>
>>
>>>Hi,
>>>
>>>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.
>>
>>
>> Hi Michael,
>>
>> It is just a shorthand notation for an if-then-else statement
>
> Not quite. You couldn't use it for something like:
>
> if (6 == $a)
> {
> for ($i = 0; $i < $a; ++i)
> {
> ...
> }
> }
> else
> {
> // Some other code
> }
>
>
> It's really a conditional assignment operator.

True.
:-)

Regards,
Erwin Moller
Received on Tue Oct 18 02:40:03 2005