+ 1
OUTPUT WITH EXPLANATION...
<?php $var = true?'1':false?'2':'3'; echo $var; ?>
3 Réponses
+ 2
Sorry, I don't know why I didn't see it, but here's the explanation:
You can look at it like this:
(true? '1': false)? '2': '3';
In the parentheses, it will be 1, which is evaluated to true, therefore the output is 2
+ 2
THE OUTPUT IS 1. THIS CODE USES THE TERNARY OPERATOR, WHICH WORKS LIKE THIS:
condition? condition == true: condition == false;
true IS OBVIOUSLY EVALUATED TO TRUE, SO IT WILL BE THE FIRST OPTION, WHICH IS 1
+ 1
Airree but the output is 2. Why?