三元运算符 php_使用PHP三元运算符

三元运算符 php

You’re probably already familiar with PHP’s if statement. It’s very similar to its counterparts in many other programming languages and represents one of the most fundamental concepts in programming. The if statement is easy to understand and easy to master. This is probably what you’re used to:

您可能已经熟悉PHP的if语句。 它与许多其他编程语言中的对应语言非常相似,并且代表了编程中最基本的概念之一。 if语句易于理解且易于掌握。 这可能是您习惯的:

= 10) {
    $message = "You are one cool dude!";
}
else {
    $message = "Sorry, you aren't that cool!";
}

But there’s a way to build on this concept and increase your $coolFactor a bit in the process. Allow me to introduce you to the ternary operator, which serves as a shorthand notation for if statements.

你可能感兴趣的:(java,python,php,javascript,深度学习,ViewUI)