remember not every short code is a good one. in your example there's no single way to hit this else if
because you're saying
if($var === "hello")
{
// if the condetion is true
"Hi";
}
else
{
// if the condetion is false
"Goodbye";
}
// error here
else if($var ==="howdie")
{ "how"; }
else
{ "Goodbye"; }
this's wrong you can't use two else
s respectively. you've structure your conditions like
if (condition) {
# code...
} elseif (condition) {
# code...
} else {
}
the same in the ternary operators
(condition) ? /* value to return if first condition is true */
: ((condition) ? /* value to return if second condition is true */
: /* value to return if condition is false */ );
and beware of (
,)
in the second condition.
and as you see your code is just going to be tricky, unreadable and hard to trace. so use the if else if
if you've more than one condition switching
and revise your logic.