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

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 written: This … Read more

What is ‘\0’ in C++?

‘\0′ equals 0. It’s a relic from C, which doesn’t have any string type at all and uses char arrays instead. The null character is used to mark the end of a string; not a very wise decision in retrospect – most other string implementations use a dedicated counter variable somewhere, which makes finding the end of … Read more

What does `<>` mean in Python?

It means not equal to. It was taken from ABC (python’s predecessor) see here: x < y, x <= y, x >= y, x > y, x = y, x <> y, 0 <= d < 10 Order tests (<> means ‘not equals’) I believe ABC took it from Pascal, a language Guido began programming with. It has now been removed in … Read more

Not equal to != and !== in PHP

== and != do not take into account the data type of the variables you compare. So these would all return true: === and !== do take into account the data type. That means comparing a string to a boolean will never be true because they’re of different types for example. These will all return false: You should compare data types for functions that … Read more

The tilde operator in Python

It is a unary operator (taking a single argument) that is borrowed from C, where all data types are just different ways of interpreting bytes. It is the “invert” or “complement” operation, in which all the bits of the input data are reversed. In Python, for integers, the bits of the twos-complement representation of the integer are … Read more

What does question mark and dot operator ?. mean in C# 6.0?

It’s the null conditional operator. It basically means: “Evaluate the first operand; if that’s null, stop, with a result of null. Otherwise, evaluate the second operand (as a member access of the first operand).” In your example, the point is that if a is null, then a?.PropertyOfA will evaluate to null rather than throwing an exception – it will then compare that null reference with foo (using string’s == overload), … Read more

Reference — What does this symbol mean in PHP?

Incrementing / Decrementing Operators ++ increment operator — decrement operator These can go before or after the variable. If put before the variable, the increment/decrement operation is done to the variable first then the result is returned. If put after the variable, the variable is first returned, then the increment/decrement operation is done. For example: Live example In the case above ++$i is … Read more

Regex how to match an optional character

Use to make the letter optional. {1} is redundant. (Of course you could also write [A-Z]{0,1} which would mean the same, but that’s what the ? is there for.) You could improve your regex to And, since in most regex dialects, \d is the same as [0-9]: But: do you really need 11 separate capturing groups? And if so, why don’t you capture the … Read more

PowerShell and the -contains operator

The -Contains operator doesn’t do substring comparisons and the match must be on a complete string and is used to search collections. From the documentation you linked to: -Contains Description: Containment operator. Tells whether a collection of reference values includes a single test value. In the example you provided you’re working with a collection containing just one string … Read more

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