有没有一种好方法可以将 css 类作为 PHP if else 语句的一部分调用?我要做的是根据 php if else 语句的结果值更改作为 html 一部分的 div 的背景颜色。
php
if(!empty($check_availability)){
echo <div id="1"> do something <div>
// make the div background green if this is true
}
else {
<div id="2"> do something else instead<div>
//make backgound red if this is true
}
html
<div id="container"> <!-- <<<<<<< this is the div that I want to change the background color of depending on results from the php -->
<div id="1"></div>
<div id="2"></div>
</div>