What difference is there between using the
?: conditional operator and the
I am finding that my code works with:
$screenpixelratio = !empty($_COOKIE['screenpixelratio']) || $_COOKIE['screenpixelratio'] || $fallback_pixelratio;
$screenpixelratio = !empty($_COOKIE['screenpixelratio']) ? $_COOKIE['screenpixelratio'] : $fallback_pixelratio;
Could someone please explain why it would work with one, but not the other.
|| Binary operators are operators that deal with two arguments
as its says it will check first if its true than not gonna check further else check further
?: ternary operator is an operator that takes three arguments. The arguments and result can be of different types.
Expression1 ? Expression2 : Expression3;
The first (conditional or) is saying…
this or this or this
The other (ternary operation) is saying
if this then this otherwise that