phprockers-logo

Explain the ternary conditional operator in PHP?

Expression preceding the ? is evaluated, if it’s true, then the expression preceding the : is executed, otherwise, the expression following : is executed. 

if(exp1?exp2:exp3 )

If exp1 condition is true, exp2 will be print. If exp1 is false, exp3 will be print.

0 comments:

Post a Comment