I have:
echo '<ul id="my-list" class="'.(true) ? 'classA' : 'classB'.'">';
But the HTML is not being output, only the text classA is being outputted to the page.
Where am I going wrong?
I have:
echo '<ul id="my-list" class="'.(true) ? 'classA' : 'classB'.'">';
But the HTML is not being output, only the text classA is being outputted to the page.
Where am I going wrong?
Try to use additionnal parenthesis :
echo '<ul id="my-list" class="'.((true) ? 'classA' : 'classB').'">';
Because the concatenation operator( like the majority of operators in php) will cast the object to its right to the same type as the object on its left .