View Full Version : Tip: PHP Ternary operator
Chris
03-03-2004, 01:37 PM
This is a useful way to write your PHP if/else statements. It is called the Ternary operator.
(expr1) ? (expr2) : (expr3);
It says if expr1 is true then evaluate expr2 else evaluate expr3.
Here is the same thing using if/then:
if(expr1) {
expr2
} else {
expr3
}
It certainly makes for some cleaner code.
Use the word ternary in a sentence not related to programming, I dare you.
Use the word ternary in a sentence not related to programming, I dare you.
The ternary nature of God can be very confusing.
Ternary periods seems to be unique to hockey.
-- Dave
OK, you did it. But it took you a whole year to come up with 2 examples. :D
OK, you did it. But it took you a whole year to come up with 2 examples. :D
Yeah but it took me less than 5 minutes to come up with with them.
The real challenge will be to use 'ternary' in a poem.... That may take a while. :confused:
-- Dave
I'm way to weary to rhyme 'Ternary'
And if I could It'd be way to scary.
rckwldrn
10-06-2007, 11:36 AM
Use the word ternary in a sentence not related to programming, I dare you.
Ternary A musical form consisting of three main sections.
"Today i wrote a ternary song, it had only a verse, a chorus and a bridge"
vBulletin® v3.7.1, Copyright ©2000-2010, Jelsoft Enterprises Ltd.