class 在 div 中使用 php echo

class within an div using php echo

基本上只是想知道是否可以使用 if 语句向我的 div 添加 class,我 echo

我的代码:

$currentpage = $_SERVER['REQUEST_URI'];

if ($currentpage == "/room/penthouse-suite/"){
echo "<div class="' .text-center text-emphasis text-lg. '">test 
penthouse</div>";
}
elseif ($currentpage == "/room/garden-room/"){
echo "<div class="text-center text-emphasis text-lg">test garden</div>";
}
elseif ($currentpage == "/room/ocean-suite/"){
echo "<div class='text-center text-emphasis text-lg'>test ocean</div>";
}
elseif ($currentpage == "/room/mountain-suite/"){
echo "<div class='text-center text-emphasis text-lg'>test mountain</div>";
}

如您所见,我确实尝试了几种方法,但没有成功。

双引号内不应使用双引号,单引号内不应使用单引号。我解决了这个替换引号。请试试这个

if ($currentpage == "/room/penthouse-suite/") {
            echo '<div class="text-center text-emphasis text-lg">test 
penthouse</div>';
        } elseif ($currentpage == "/room/garden-room/") {
            echo '<div class="text-center text-emphasis text-lg">test garden</div>';
        } elseif ($currentpage == "/room/ocean-suite/") {
            echo "<div class='text-center text-emphasis text-lg'>test ocean</div>";
        } elseif ($currentpage == "/room/mountain-suite/") {
            echo "<div class='text-center text-emphasis text-lg'>test mountain</div>";
        }

已解决

基本上只是在双引号中使用单引号。(简单)

if ($currentpage == "/room/penthouse-suite/"){
echo "<div class='text-center text-emphasis text-lg'>test 
penthouse</div>";
}
elseif ($currentpage == "/room/garden-room/"){
echo "<div class='text-center text-emphasis text-lg'>test garden</div>";
}
elseif ($currentpage == "/room/ocean-suite/"){
echo "<div class='text-center text-emphasis text-lg'>test ocean</div>";
}
elseif ($currentpage == "/room/mountain-suite/"){
echo "<div class='text-center text-emphasis text-lg'>test mountain</div>";
}