views:

1440

answers:

2

Possible Duplicate:
quick php syntax question

return $add_review ? FALSE : $arg;

What do question mark and colon mean?

Thanks

+7  A: 

This is the PHP ternary operator (also known as a conditional operator) - if first operand evaluates true, evaluate as second operand, else evaluate as third operand.

Think of it as an "if" statement you can use in expressions. Can be very useful in making concise assignments that depend on some condition, e.g.

$param=isset($_GET['param']) ? $_GET['param'] : 'default';
Paul Dixon
A: 

It's the ternary form of the if-else operator. The above statement basically reads like this:

if ($add_review) then {
    return FALSE; //$add_review evaluated as True
} else {
    return $arg //$add_review evaluated as False
}

See here for more details on ternary op in PHP: http://www.addedbytes.com/php/ternary-conditionals/

Cristian Ivascu