What is the correct way to use an IF/ELSE statement inside of a variable string?
Example:
$htmlOutput = 'The current color of the sky is ' .
if ($time==="day") { . 'blue.' . }
else if ($time==="night") { . 'black' . };
Obviously that example does not work, but you see what I'm trying to do. I know I could just continue the variable inside of the if statement like:
$htmlOutput .= '';
but I'm curious if there's a way to do it as stated above.
if x then y else zin a ternary operation though. They can be nested but it quickly becomes very unreadable.(if x then (if a then b else c) else z)