Operator "?" in PHP, what's the use? [duplicate]

0

I'm studying php, I got a code to tinker and I'm not finding reference to the question mark in php, which is in the example below, for what it is.

$dinheiro = $debito <= 1 ? FALSE : TRUE;
    
asked by anonymous 29.06.2015 / 04:45

1 answer

4

It's called Ternary Operator.

This means that if the value of $ debit is less than or equal to one, the variable $ money is FALSE, otherwise it is set to True.

This can be compared to:

if($debito<=1)
{
   $dinheiro = false;
}
else
{
   $dinheiro = true;
}
    
29.06.2015 / 09:25