Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if/else? switch? 3

Status
Not open for further replies.

DaveC426913

Programmer
Jul 28, 2003
274
CA
What's this called (it *is* a legit PHP construct, right?):

true?doA():doB();

It is the equivalent of:

if (true){ doA; }
else {do B; }

I just want to make sure that the FIRST statment is executed if true, the SECOND if false. Right?
 
Yes, it is. And you're right, it's equivalent. It's a shorthand for the if-then-else statements.

$x = $a == 5 ? true : notfive();

$x will be true if $a == 5, or the return value from function notfive() otherwise.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top