PHP syntax question: What does the question mark and colon mean? [duplicate]

This is the PHP ternary operator (also known as a conditional operator) – if first operand evaluates true, evaluate as second operand, else evaluate as third operand. Think of it as an “if” statement you can use in expressions. Can be very useful in making concise assignments that depend on some condition, e.g. $param = … Read more

Ternary operator in Java only evaluating one expression since Java 7 – was that different in Java 1.6 and lower?

From the Java 6 JLS: At run time, the first operand expression of the conditional expression is evaluated first; if necessary, unboxing conversion is performed on the result; the resulting boolean value is then used to choose either the second or the third operand expression: If the value of the first operand is true, then … Read more

Angularjs if-then-else construction in expression

Angular expressions do not support the ternary operator before 1.1.5, but it can be emulated like this: condition && (answer if true) || (answer if false) So in example, something like this would work: <div ng-repeater=”item in items”> <div>{{item.description}}</div> <div>{{isExists(item) && ‘available’ || ‘oh no, you don’t have it’}}</div> </div> UPDATE: Angular 1.1.5 added support … Read more

Java ternary operator vs if/else in

When you think about the type of the operands, the problem becomes more apparent: this.method != null ? this.method : this.constructor has as type the most specialized common type of both the operands, i.e. the most specialized type common to both this.method and this.constructor. In Java 7 this is java.lang.reflect.Member, however the Java 8 class … Read more

What is a Question Mark “?” and Colon “:” Operator Used for? [duplicate]

This is the ternary conditional operator, which can be used anywhere, not just the print statement. It’s sometimes just called “the ternary operator”, but it’s not the only ternary operator, just the most common one. Here’s a good example from Wikipedia demonstrating how it works: A traditional if-else construct in C, Java and JavaScript is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)