Forum Moderators: coopster

Message Too Old, No Replies

What does this return?

         

Habtom

6:40 am on Apr 23, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What does this return?

return ($num)? $num:1;

Habtom

mikesmith76

9:49 am on Apr 23, 2006 (gmt 0)

10+ Year Member



depends entirely on what it's used for. It's a shorthand if statement, the bit in brackets is the condition and the other parts are what to return if the conditio is true, then false

MyGen

10:49 am on Apr 23, 2006 (gmt 0)

10+ Year Member



"Return $num if $num exists, else return 1"

coopster

12:41 pm on Apr 23, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



It's called the Ternary Operator [php.net], Habtom. It is another of PHP's Comparison Operators.

Habtom

1:50 pm on Apr 23, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks all. Thanks coopster.

Habtom