Home >Common Problem >What is the ternary operator
Detailed explanation of ternary operator
For some selection branch structures, simple conditional operators can be used instead . For example:
if(a<b) min=a; else min=b;
You can use the following conditional operator to process
min=(a<b)?a:b;
where "(a7ad0d49c44c8e71e5b95351995aac2f2=0)?a:-a The execution result is the absolute value of a
(3) In the program, by changing the conditional expression The value is assigned directly to a variable. For example:
min=(a9eabeac4c8818aad73659d9842465a49='A'&&ch<='Z' is true, explain ch is an uppercase English letter, so select @ at this time; otherwise, still select the original character ch, and then assign the selected result to the original variable ch.
The above is the detailed content of What is the ternary operator. For more information, please follow other related articles on the PHP Chinese website!