Home  >  Article  >  What is the ternary operator

What is the ternary operator

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-07-30 16:19:5027296browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn