PHP shorthand for isset()? [duplicate]

Update for PHP 7 (thanks shock_gone_wild) PHP 7 introduces the null coalescing operator which simplifies the below statements to: $var = $var ?? “default”; Before PHP 7 No, there is no special operator or special syntax for this. However, you could use the ternary operator: $var = isset($var) ? $var : “default”; Or like this: … Read more

Which “if” construct is faster – statement or ternary operator?

There’s only one type of “if” statement there. The other is a conditional expression. As to which will perform better: they could compile to the same bytecode, and I would expect them to behave identically – or so close that you definitely wouldn’t want to choose one over the other in terms of performance. Sometimes … Read more

shorthand http:// as // for script and link tags? anyone see / use this before?

Starting a URL with // means “Use a different server but keep the same scheme” So if you load //example.net/script from https://example.com/ it will get https://example.net/script, while if you load it from http://example.com/ it will get http://example.net/script. If, on the other hand, you load it from file://c:/Users/You/Documents/test.html then it will probably not resolve to anything … Read more

CSS transition shorthand with multiple properties?

Syntax: transition: <property> || <duration> || <timing-function> || <delay> [, …]; Note that the duration must come before the delay, if the latter is specified. Individual transitions combined in shorthand declarations: -webkit-transition: height 0.3s ease-out, opacity 0.3s ease 0.5s; -moz-transition: height 0.3s ease-out, opacity 0.3s ease 0.5s; -o-transition: height 0.3s ease-out, opacity 0.3s ease 0.5s; … Read more