UBB.Dev
Posted By: JohnM [PHP] Cool little trick - 12/31/2000 1:55 AM
I just read about this in the PHP manual:

$variable = (expression1 ? expression2 : expression3);

$variable will result in expression2 if expression1 evaluates to true, or expression3 if it is false.

and then there's double, or even triple:

Code
code:

------------------
Posted By: Mark Badolato Re: [PHP] Cool little trick - 01/01/2001 10:54 AM
That's the ternary operator. Perl and other languages use it too.

--mark
Posted By: The Team Re: [PHP] Cool little trick - 01/01/2001 7:41 PM
Ternary = good, eh Mark? [Linked Image]

------------------


:: Who is Andy?

This message has been edited by atom911 on January 01, 2001 at 11:41 AM
Posted By: JohnM Re: [PHP] Cool little trick - 01/01/2001 8:19 PM
I've seen it in Perl and stuff before, but I didn't know PHP had it.

------------------
Posted By: cal Re: [PHP] Cool little trick - 01/02/2001 11:38 AM
Allows for even tighter (and easier to read) code in perl. excellent.

Just a thought [Linked Image]

------------------
http://www.iamcal.com
© UBB.Developers