Re: what does this line means? Many thanks
| From: | Franklin van Velthuizen | Date: | Wed, 05 Sep 2001 22:25:42 +0000 |
| Subject: | Re: what does this line means? Many thanks | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-66118@lists.php.net to get a copy of this message | ||
> thanks, another question is what does the ? means in this line?
From the PHP manual:
<snip>
Another conditional operator is the "?:" (or ternary) operator, which
operates as in C and many other languages.
(expr1) ? (expr2) : (expr3);
This expression evaluates to expr2 if expr1 evaluates to TRUE, and expr3 if
expr1 evaluates to FALSE.
</snip>
So, this would print "yes":
print(true ? "yes" : "no");
And so would this:
true ? print("yes") : print("no");
And this would print "no":
print(false ? "yes" : "no");
And so would this:
false ? print("yes") : print("no");
Hope that's enough info.
/ franklin