Php ternary operations $ a2; $ a1? $ Test & quot; Enterprise & quot; :( $ a2? $ Test & quot; Region & quot;: $ test & quot; other places & quot;); echo $ test; first, judge whether $ a is 1. if it is a direct output enterprise, if it is not to continue to judge, it is equivalent to another nested if in else. if it is equal to 2, if it is not to input the php trielement operation
$ A = 2;
$ A = 1? $ Test = "enterprise": ($ a = 2? $ Test = "region": $ test = "other places ");
Echo $ test;
First, judge whether $ a is 1. if it is a direct output enterprise, if it is not, continue to judge whether it is equivalent to another nested if in else. if it is equal to 2, the output region is not output elsewhere.
Equivalent
$ A = 2;
If ($ a = 1 ){
Echo $ test = "enterprise ";
} Else {
If ($ a = 2 ){
$ Test = "region ";
} Else {
$ Test = "other places ";
}
}
Echo $ test;
Or
If ($ a = 1 ){
Echo $ test = "enterprise ";
} Else {
$ A = 2? $ Test = "region": $ test = "other places ";
}