The behaviour of the or operator in PHP

The basics: An assignment expression results in the assigned value. What does that mean? $foo = ‘bar’ is an expression, in which the assignment operator = assigns a value. An expression always returns a value itself. Just like the expression 1 + 2 results in the value 3, the expression $foo = ‘bar’ results in … Read more

Angular 2 ngSwitchCase, OR operator not working

If you evaluate ‘d’ || ‘e’ || ‘f’ the result is ‘d’ and when options is not ‘d’, then it doesn’t match. You can’t use ngSwitchCase that way. This would work: <ng-container [ngSwitch]=”true”> <ng-container *ngSwitchCase=”options === ‘a'”>Code A</ng-container> <ng-container *ngSwitchCase=”options === ‘b'”>Code B</ng-container> <ng-container *ngSwitchCase=”options === ‘c'”>Code C</ng-container> <ng-container *ngSwitchCase=”options === ‘d’ || options === … Read more

Shortcut “or-assignment” (|=) operator in Java

The |= is a compound assignment operator (JLS 15.26.2) for the boolean logical operator | (JLS 15.22.2); not to be confused with the conditional-or || (JLS 15.24). There are also &= and ^= corresponding to the compound assignment version of the boolean logical & and ^ respectively. In other words, for boolean b1, b2, these … Read more

What does “var FOO = FOO || {}” (assign a variable or an empty object to that variable) mean in Javascript?

Your guess as to the intent of || {} is pretty close. This particular pattern when seen at the top of files is used to create a namespace, i.e. a named object under which functions and variables can be created without unduly polluting the global object. The reason why it’s used is so that if … Read more

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