It seems rather handy. I'm playing around with it to make the code a little more sensible. All the if/else statements get a little l-o-o-o-n-g for short things.
Vincent Puglia posted this at 10:51 — 16th August 2003.
I wasn't around for 65, on the wrong side for 77, lucky me, moved back for 03.
I was trying to find out what it was called because I couldn't dig up information without the real term. I wanted to see if I could, er, force it to do something else. (I can't -- but I figured it out anyway).
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.
Suzanne posted this at 01:36 — 16th August 2003.
She has: 5,507 posts
Joined: Feb 2000
ternary operator is what it's called. Whee! nevermind.
http://uk.php.net/language.operators.comparison for more info (it's the example)
Mark Hensler posted this at 01:39 — 16th August 2003.
He has: 4,048 posts
Joined: Aug 2000
lol
It operates exactly like this:
if (condition) { true_statement } else { false_statement }
I find it very usefull for inline conditions. For example, making things plural...
echo $months.' month'.($months==1 ? '' : 's');
possible ouputs:
0 months
1 month
2 months
3 months
Mark Hensler
If there is no answer on Google, then there is no question.
Suzanne posted this at 01:41 — 16th August 2003.
She has: 5,507 posts
Joined: Feb 2000
It seems rather handy. I'm playing around with it to make the code a little more sensible. All the if/else statements get a little l-o-o-o-n-g for short things.
Vincent Puglia posted this at 10:51 — 16th August 2003.
They have: 634 posts
Joined: Dec 1999
Hi Suzanne,
It's the same in javascript:
var myVar = (conditional) ? trueStatement : falseStatement;
btw: that makes 3 blackouts for me (65,77,03)
Vinny
Where the world once stood
the blades of grass cut me still
Suzanne posted this at 16:30 — 16th August 2003.
She has: 5,507 posts
Joined: Feb 2000
I wasn't around for 65, on the wrong side for 77, lucky me, moved back for 03.
I was trying to find out what it was called because I couldn't dig up information without the real term. I wanted to see if I could, er, force it to do something else. (I can't -- but I figured it out anyway).
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.